Why does MATLAB run out of Java heap space when my machine changes display settings?

9 views (last 30 days)
When MATLAB is running, it occasionally crashes with the following errors. It happens after multiple occurrences of certain events such as computer sleeping, laptop connecting to a bigger monitor, screensaver activating, and other display effects.
[ConditionalEventPump] Exception occurred during event dispatching:
java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(Unknown Source)
at java.awt.image.Raster.createPackedRaster(Unknown Source)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at sun.awt.image.SunVolatileImage.getBackupImage(Unknown Source)
at sun.awt.image.VolatileSurfaceManager.getBackupSurface(Unknown Source)
at sun.awt.image.VolatileSurfaceManager.initialize(Unknown Source)
at sun.awt.image.SunVolatileImage.<init>(Unknown Source)
at sun.awt.image.SunVolatileImage.<init>(Unknown Source)
at java.awt.GraphicsConfiguration.createCompatibleVolatileImage(Unknown Source)
at java.awt.GraphicsConfiguration.createCompatibleVolatileImage(Unknown Source)
at javax.swing.RepaintManager.getVolatileOffscreenBuffer(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
...

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Jul 2013
NOTE: This solution refers to a specific Java bug with specific symptoms. However, there are many reasons where
java.lang.OutOfMemoryError: Java heap space
errors may occur. A lot of these cases are not related and can be fixed by increasing the Java heap space. Be sure to compare the listed error log and trigger mechanisms to determine whether the issue you are seeing is in fact related to this solution.
The MATLAB crash is due to a bug in the Java 1.6 Virtual Machine and may affect MATLAB releases R2007b to R2013a which utilize JVM 1.6.
In this version of the JVM, a memory leak occurs if screen resolution is changed. A screen resolution change event may occur with activities such as:
-- Using a screen saver that changes your display settings
-- Adding or removing displays, e.g. connecting an external monitor or a beamer to your laptop
-- Opening/closing the lid of your laptop when it is connected to an external monitor
-- Playing a movie in full screen
-- Playing games that change the display settings
-- Using remote desktop applications that change video settings, e.g. Microsoft Remote Desktop Connection, Netmeeting, Webex, VNC
The Oracle bug report (6990010) can be found at the following link:
Possible workarounds include:
1. Try increasing the Java heap space. See the related solutions below.
2. If you do not need the JVM to be active with the MATLAB session (most MATLAB GUI and graphics functionality depend on the JVM), you can disable it by starting MATLAB without the JVM. To do this, start MATLAB from a system command window with the
-nojvm
option.
3. Try using a newer version of the JVM with MATLAB (1.7 or higher). You can do this by setting the MATLAB_JAVA system environment variable to point to the JRE root, such as:
C:\Program Files\Java\jdk1.7.0_10\jre
WARNING: Using a major version of Java that does not ship with MATLAB is not tested and not supported. There have been known issues with using an alternate version of Java (usually with the desktop and display capabilities). If problems occur, we may not be able to help. Only exercise this option after thorough testing.
4. Try to avoid the situations that may change your display settings.
  1 Comment
Abhishek Pandey
Abhishek Pandey on 19 Apr 2016
Hi Christoph,
This issue has not been fixed yet. This essentially occurs due to some Java memory leakage which is not completely in the developers' control. The bug has been created with Oracle, but as of now, there are no updates. I hope this helps!
- Abhishek

Sign in to comment.

More Answers (0)

MathWorks Support

Categories

Find more on Performance and Memory in Help Center and File Exchange

Products


Release

R2010a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!