Release timeout memory for scheduled tasks

Motivation:

fix memory leak

Modification:

added a new release method and it will be called in ring buffer

Result:

to avoid memory leaks
This commit is contained in:
Josef Grieb 2020-08-24 09:09:03 +02:00 committed by josef
parent 8d464d5ab4
commit 96e0e5cc91
3 changed files with 14 additions and 0 deletions

View File

@ -230,6 +230,11 @@ final class IOUringSubmissionQueue {
PlatformDependent.putLong(timeoutMemoryAddress + KERNEL_TIMESPEC_TV_NSEC_FIELD, nanoSeconds);
}
//delete memory
public void release() {
Buffer.free(timeoutMemory);
}
public void setSqeHead(long sqeHead) {
this.sqeHead = sqeHead;
}

View File

@ -34,6 +34,7 @@ final class RingBuffer {
}
public void close() {
getIoUringSubmissionQueue().release();
Native.ioUringExit(this);
}

View File

@ -164,5 +164,13 @@ public class NativeTest {
}.start();
waitingCqe.join();
ringBuffer.close();
}
@Test
public void ioUringExitTest() {
RingBuffer ringBuffer = Native.createRingBuffer();
ringBuffer.close();
}
}