Helioviewer-Project / JHelioviewer-SWHV

Space Weather JHelioviewer ☉
https://swhv.oma.be
Mozilla Public License 2.0
49 stars 16 forks source link

Java OOM while exporting movie with 2GB heap #182

Closed farm24 closed 2 years ago

farm24 commented 2 years ago

it says to put this log in it

Log: 2021-12-01 10:05:05,622 [main] INFO root - JHelioviewer started with command-line options: 2021-12-01 10:05:05,834 [main] INFO root - JHV/SWHV-4.1.1.10360 (x86_64 Mac OS X 11.5) Eclipse Adoptium JRE 17 2.0GB 8CPU 2021-12-01 10:05:08,794 [main] TRACE class org.ehcache.core.Ehcache-JPIPLevel - Initializing 2021-12-01 10:05:08,883 [main] DEBUG class org.ehcache.core.Ehcache-JPIPLevel - Initialize successful. 2021-12-01 10:05:08,931 [main] TRACE class org.ehcache.core.Ehcache-JPIPStream - Initializing 2021-12-01 10:05:08,996 [main] DEBUG class org.ehcache.core.Ehcache-JPIPStream - Initialize successful. 2021-12-01 10:05:10,426 [AWT-EventQueue-0] INFO root - Start main window 2021-12-01 10:05:13,741 [AWT-EventQueue-0] INFO root - Load bundled plugins 2021-12-01 10:05:15,218 [AWT-EventQueue-0] INFO root - GLInfo > OpenGL 4.1 Metal - 71.7.1 2021-12-01 10:07:35,696 [Worker] DEBUG root - Response: {"frames":876,"message":"Movie cadence has been changed to one image every 28681 seconds between your requested start and end dates in order to avoid exceeding the maximum of 1000 frames allowed per request.","uri":"jpip://helioviewer.ias.u-psud.fr:8080//movies/SOHO_LASCO_C2_white-light_F2021-01-01T15.31.30Z_T2021-11-29T15.31.30ZB1L.jpx"} 2021-12-01 10:16:43,711 [Worker] DEBUG root - Response: {"frames":873,"message":"Movie cadence has been changed to one image every 28681 seconds between your requested start and end dates in order to avoid exceeding the maximum of 1000 frames allowed per request.","uri":"jpip://helioviewer.ias.u-psud.fr:8080//movies/SOHO_LASCO_C3_white-light_F2021-01-01T15.31.30Z_T2021-11-29T15.31.30ZB1L.jpx"} 2021-12-01 10:26:06,681 [AWT-EventQueue-0] ERROR root - Runtime exception com.jogamp.opengl.GLException: Caught OutOfMemoryError: Cannot reserve 3981600 bytes of direct buffer memory (allocated: 2142163480, limit: 2147483648) on thread AWT-EventQueue-0 at com.jogamp.opengl.GLException.newGLException(GLException.java:76) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at com.jogamp.opengl.awt.GLCanvas$12.run(GLCanvas.java:1442) at com.jogamp.opengl.Threading.invoke(Threading.java:223) at com.jogamp.opengl.awt.GLCanvas.display(GLCanvas.java:503) at org.helioviewer.jhv.layers.MovieDisplay.lambda$display$0(MovieDisplay.java:21) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Caused by: java.lang.OutOfMemoryError: Cannot reserve 3981600 bytes of direct buffer memory (allocated: 2142163480, limit: 2147483648) at java.base/java.nio.Bits.reserveMemory(Bits.java:178) at java.base/java.nio.DirectByteBuffer.(DirectByteBuffer.java:121) at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:332) at org.helioviewer.jhv.base.image.NIODataBuffer.(NIODataBuffer.java:16) at org.helioviewer.jhv.base.image.NIODataBuffer$DataBufferInt.(NIODataBuffer.java:106) at org.helioviewer.jhv.base.image.NIODataBuffer.create(NIODataBuffer.java:42) at org.helioviewer.jhv.base.image.NIOImageFactory.createCompatible(NIOImageFactory.java:42) at org.helioviewer.jhv.base.image.NIOImageFactory.createCompatible(NIOImageFactory.java:29) at org.helioviewer.jhv.base.image.NIOImageFactory.copyImage(NIOImageFactory.java:16) at org.helioviewer.jhv.export.ExportMovie.handleMovieExport(ExportMovie.java:50) at org.helioviewer.jhv.opengl.GLListener.display(GLListener.java:172) at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674) at com.jogamp.opengl.awt.GLCanvas$11.run(GLCanvas.java:1428) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293) ... 18 more

bogdanni commented 2 years ago

OpenGL 4.1 Metal - 71.7.1

What computer is that? Is it by chance a M1?

farm24 commented 2 years ago

OpenGL 4.1 Metal - 71.7.1

What computer is that? Is it by chance a M1?

Yes it is a MacBook Air M1

bogdanni commented 2 years ago

This is not supported yet, sorry. I'm surprised the program even reached that stage, I had the impression that Java would not go very far since it generates CPU instructions at runtime, and the M1 Macs do a binary instruction translation at startup.

Did the program actually manage to start completely and draw without an image layer?

bogdanni commented 2 years ago

If it starts completely, could you please post here a screenshot of the window?

farm24 commented 2 years ago
Screen Shot 2021-12-01 at 3 13 09 PM

not only did it start up but i have been using it flawlessly for about a month

bogdanni commented 2 years ago

Wow, absolutely amazing! Thank you for sharing this, I was convinced it doesn't work at all...

Looking again through your log trace, your Java actually runs out of memory while exporting a very long movie. Here's how to bypass this problem. You will need to ask Java to allocate more at startup.

Open the Terminal application, then type:

cd /Applications/JHelioviewer.app/Contents/Resources/app/classes
../../jre.bundle/Contents/Home/bin/java -Xmx4g --add-exports java.desktop/sun.awt=ALL-UNNAMED -cp JHelioviewer.jar:natives-macos.jar org.helioviewer.jhv.JHelioviewer

Then, when it is started, verify in the About box that it says 4.0GB. You notice in your initial report it was logged:

JHV/SWHV-4.1.1.10360 (x86_64 Mac OS X 11.5) Eclipse Adoptium JRE 17 **2.0GB** 8CPU

Your computer probably has 8GB RAM (default configuration) and Java allocated for itself 2GB.

bogdanni commented 2 years ago

If you don't need to export the image of timelines, you can also click on the divider between the image canvas and timeline canvas. That will collapse the timelines part and will use less memory during exporting.

farm24 commented 2 years ago

If you don't need to export the image of timelines, you can also click on the divider between the image canvas and timeline canvas. That will collapse the timelines part and will use less memory during exporting.

I think I’m going to do this because I can’t access the terminal app because it’s a school computer

bogdanni commented 2 years ago

I've put up a build of the next version at http://swhv.oma.be/download_test/ It contains a change that will make it much more unlikely to run out of Java virtual machine memory. I've tested it in some pretty extreme conditions.

In any case, if you don't need to have the timelines panel displayed in the resulting movie, please collapse it. The crash was coming from the extra memory and processing needed for that panel.

farm24 commented 2 years ago

oh ok thank you