OutOfMemory Exception
Martin Pernollet
martin.pernollet at protonmail.com
Sun Jan 22 17:09:33 UTC 2023
Hi,
After switching PanamaGL from JDK17 to JDK19, I am facing an OutOfMemory exception.
The part where this occurs is in the loop that performs offscreen rendering and then copy the result to a BufferedImage later used for onscreen rendering.
This allocation
intnBytes=width*height*channels;
MemorySegmentpixelsRead= MemorySegment.allocateNative(nBytes,scope);
gl.glReadPixels(0,0,width,height,format,textureType,pixelsRead);
Fails as follow
java.lang.OutOfMemoryError: Cannot reserve 2169600 bytes of direct buffer memory (allocated: 4293080163, limit: 4294967296)
at java.base/java.nio.Bits.reserveMemory(Bits.java:178)
at java.base/java.nio.Buffer$1.reserveMemory(Buffer.java:860)
at java.base/jdk.internal.foreign.NativeMemorySegmentImpl.makeNativeSegment(NativeMemorySegmentImpl.java:122)
at java.base/java.lang.foreign.MemorySegment.allocateNative(MemorySegment.java:965)
at java.base/java.lang.foreign.MemorySegment.allocateNative(MemorySegment.java:942)
As shown on the VisualVM screenshot the heap grows at the beginning but is then freed. The exception happens when the heap reduces suddenly on the chart.
[Capture d’écran 2023-01-22 à 17.48.40.png]
The behavior is the same for all possible scopes provided by MemorySession (global, openConfined, openShared, openImplicit.
One thing : I can not unload() the MemorySegment when I am done using it (but this was also not possible in JDK17).
How could I track this memory leak? How could I ensure that useless memory get destroyed?
Thanks in advance,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230122/aed54529/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture d?e?cran 2023-01-22 a? 17.48.40.png
Type: image/png
Size: 36259 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230122/aed54529/Capturedecran2023-01-22a17.48.40-0001.png>
More information about the panama-dev
mailing list