Skip to content

Commit 3162738

Browse files
committed
#65: Delete memory mapped buffer on close
Unfortunately, the current solution requires a garbage collect to have been performed before the issue is resolved. Other fixes required either a Java 8 Cleaner.clean() call not accessible from Java 21, or a Java 20 Arena.close(), which is not been finalized in Java 21.
1 parent 8bc43fc commit 3162738

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/main/java/com/riscure/trs/TraceSet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ private void checkValid(Trace trace) {
338338
}
339339

340340
private void closeReader() throws IOException {
341+
buffer = null;
341342
readStream.close();
342343
}
343344

src/test/java/TestTraceSet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,11 @@ void testFileReleasing() throws IOException, TRSFormatException, InterruptedExce
675675
try (TraceSet traceSet = TraceSet.open(filePath)) {
676676
traceSet.getMetaData().getTraceSetParameters();
677677
}
678+
// Unfortunately, the current solution requires a garbage collect to have been performed before the issue is resolved.
679+
// Other fixes required either a Java 8 Cleaner.clean() call not accessible from Java 21, or a Java 20 Arena.close(),
680+
// which is not been finalized in Java 21.
681+
System.gc();
682+
Thread.sleep(1000);
678683
// Assert that the opened file has been closed again, by deleting it.
679684
File file = new File(filePath);
680685
assert(file.delete());

0 commit comments

Comments
 (0)