-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing memory leaks in runtime-integration-tests #10793
Conversation
Making sure that resources are properly closed when test suits are done. Previously memory usage in Java tests was steadily rising until ~8GB. Now, we only see jumps in the last tests but the baseline sticks to ~3GB. We are not done yet.
@@ -28,14 +28,15 @@ public static void prepareCtx() { | |||
ctx = ContextUtils.createDefaultContext(out); | |||
} | |||
|
|||
@Before | |||
@After | |||
public void resetOut() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reset @Before
is desirable to clean any debris from previous executions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also meant that we weren't cleaning up tests after runs. Double-edged sword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to do both. @Before
and @After
then.
public static void disposeCtx() { | ||
ctx.close(); | ||
} | ||
public class SignatureTest extends ContextTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extending ContextTest
is a nice trick. See also @Rule, btw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On many places in our tests, we use @Rule TemporaryFolder
. See https://github.com/enso-org/enso/blob/develop/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java#L15. Implementing ContextTest
as Rule
, we wouldn't probably need to subclass it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly sometimes sometimes we use default context, sometimes more specialized one. Sometimes we cleanup on every test case, sometimes when the whole class is done. A lot of variation tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd estimate the difference between ctx.close()
and ctx.close(); ctx = null
to be minimal, not gigabytes. But it doesn't hurt.
PackageManager.shutdown()
might be the culprit.
In any case, these changes do not hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating the issue. All the changes seems reasonable.
Updated description to reflect on the achieved/potential improvements. |
Can't read IR from an already closed context
7f67066
to
9eb3f2f
Compare
Pull Request Description
Inspired by the revert done in #10778, started looking into apparent memory leaks in
runtime-integration-tests
, written in Java.Initial state:
After:
Important Notes
Some remaining issues:
Leaving this for now, as it will probably need to be taken care by initial authors of those tests, if possible. Plus this PR leaves tests in a much better state than before.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.