Skip to content

Try harder to free memory for TString.testNoLeaks() #281

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

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,22 @@ public void initializingTensorWithRawBytes() {

@Test
public void testNoLeaks() throws Exception {
System.gc();
Thread.sleep(100);

// warm up and try to get all JIT compilation done to stabilize memory usage...
for (int i = 0; i < 1000; i++) {
TString.scalarOf(A_LARGE_STRING).close();
System.gc();
}

System.gc();
Thread.sleep(100);
long bytesBefore = Pointer.physicalBytes();

for (int i = 0; i < 1000; i++) {
TString.scalarOf(A_LARGE_STRING).close();
System.gc();
}

System.gc();
Thread.sleep(100);
long bytesAfter = Pointer.physicalBytes();

// the difference should ideally be 0, but the JVM and TF Core may be holding onto some unrelated stuff...
assertTrue(Math.abs(bytesAfter - bytesBefore) < 10_000_000);
}

Expand Down