Skip to content

Commit 9a58260

Browse files
authored
Eliminate a number of memory leaks in tests (#12414)
Memory usage has spin out of control recently when running our test-suite. Unnecessarily. This change eliminates a number of leaks that haven't been properly cleaned up on test teardown. Also closed a number of stale threads. # Important Notes Before: ![Screenshot from 2025-02-28 14-40-14](https://github.com/user-attachments/assets/25b084f9-a13d-4199-a7ab-5628d3ee421d) After: ![Screenshot from 2025-03-04 17-43-23](https://github.com/user-attachments/assets/c5b3ee34-cea0-4774-953d-42cf54bbd94c)
1 parent da89ff6 commit 9a58260

File tree

54 files changed

+432
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+432
-246
lines changed

engine/runtime-integration-tests/src/test/java/org/enso/compiler/dump/test/DocsGenerateTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static void initCtx() {
5252
public static void closeCtx() {
5353
ctx.close();
5454
ctx = null;
55+
leak.shutdown();
5556
leak = null;
5657
}
5758

engine/runtime-integration-tests/src/test/java/org/enso/compiler/test/ExecCompilerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.graalvm.polyglot.Source;
2323
import org.graalvm.polyglot.io.IOAccess;
2424
import org.hamcrest.core.AllOf;
25+
import org.junit.After;
2526
import org.junit.AfterClass;
2627
import org.junit.BeforeClass;
2728
import org.junit.Ignore;
@@ -55,6 +56,12 @@ public static void initEnsoContext() {
5556
@AfterClass
5657
public static void closeEnsoContext() throws Exception {
5758
ctx.close();
59+
ctx = null;
60+
out.close();
61+
}
62+
63+
@After
64+
public void cleanup() {
5865
out.reset();
5966
}
6067

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/ManagedResourceTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ Managed_Resource.register obj (_->0) system_resource
5353
@AfterClass
5454
public static void closeCtx() throws Exception {
5555
ctx.close();
56+
ensoCtx.shutdown();
5657
ctx = null;
58+
ensoCtx = null;
59+
newResource = null;
60+
createResource = null;
61+
getResource = null;
5762
}
5863

5964
@Test

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/RefTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public static void initCtx() throws Exception {
3535
public static void closeCtx() throws Exception {
3636
ctx.close();
3737
ctx = null;
38+
refType = null;
39+
ensoCtx.shutdown();
40+
ensoCtx = null;
3841
}
3942

4043
private static Value getRef(Value ref) {

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/progress/ProgressTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public static void initCtx() throws Exception {
3030
public static void closeCtx() throws Exception {
3131
ctx.close();
3232
ctx = null;
33+
ensoCtx.shutdown();
34+
ensoCtx = null;
3335
}
3436

3537
public ProgressTest() {}

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyOrStaticTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.Assert.assertTrue;
55

66
import java.io.ByteArrayOutputStream;
7+
import java.io.IOException;
78
import org.enso.common.LanguageInfo;
89
import org.enso.common.MethodNames;
910
import org.enso.test.utils.ContextUtils;
@@ -24,8 +25,10 @@ public void prepareCtx() {
2425
}
2526

2627
@After
27-
public void disposeCtx() {
28+
public void disposeCtx() throws IOException {
2829
ctx.close();
30+
ctx = null;
31+
out.close();
2932
}
3033

3134
@Test

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.Assert.assertTrue;
44

55
import java.io.ByteArrayOutputStream;
6+
import java.io.IOException;
67
import java.nio.charset.StandardCharsets;
78
import org.enso.interpreter.runtime.data.EnsoMultiValue;
89
import org.enso.interpreter.runtime.data.Type;
@@ -27,9 +28,10 @@ public static void initCtx() {
2728
}
2829

2930
@AfterClass
30-
public static void disposeCtx() {
31+
public static void disposeCtx() throws IOException {
3132
ctx.close();
3233
ctx = null;
34+
out.close();
3335
}
3436

3537
@Before

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static org.junit.Assert.fail;
99

1010
import java.io.ByteArrayOutputStream;
11+
import java.io.IOException;
1112
import org.enso.common.MethodNames;
1213
import org.enso.test.utils.ContextUtils;
1314
import org.graalvm.polyglot.Context;
@@ -34,9 +35,10 @@ public void resetOut() {
3435
}
3536

3637
@AfterClass
37-
public static void disposeCtx() {
38+
public static void disposeCtx() throws IOException {
3839
ctx.close();
3940
ctx = null;
41+
out.close();
4042
}
4143

4244
@Test

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpFloatTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public static void initContext() {
9090
public static void closeContext() {
9191
ctx.close();
9292
ctx = null;
93+
wrapReal = null;
9394
}
9495

9596
private final String operation;

engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpIntegerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public static void initContext() {
109109
public static void closeContext() {
110110
ctx.close();
111111
ctx = null;
112+
wrapInt = null;
112113
}
113114

114115
private final String operation;

0 commit comments

Comments
 (0)