Matlab and Robotic System Toolbox: java.lang.​OutOfMemor​yError: GC overhead limit exceeded

Hello everyone,
I am using the Robotic System Toolbox of Matlab 2015a and most of the time reading a single rosbag produces an error with the following message:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.zip.ZipCoder.getBytes(Unknown Source)
at java.util.zip.ZipFile.getEntry(Unknown Source)
at java.util.jar.JarFile.getEntry(Unknown Source)
at java.util.jar.JarFile.getJarEntry(Unknown Source)
at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
at sun.misc.URLClassPath.getResource(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.mathworks.jmi.OpaqueJavaInterface.getExceptionMessage(OpaqueJavaInterface.java:1016)
Error using org.ros.internal.message.DefaultMessageDeserializer/deserialize
Failed to retrieve Exception Message
Error in robotics.ros.BagSelection/deserializeMessages (line 444)
msg{i,1} =
robotics.ros.msg.internal.MessageFactory.newFromJava(msgType,
des.deserialize(cbuffer));
Error in robotics.ros.BagSelection/readMessages (line 194)
msgs = obj.deserializeMessages(obj.MessageList, rows);
Error in LoadMeasurements (line 47)
msgs = readMessages(bag);
The bag I am reading with
msgs = readMessages(bag);
contains some nested custom messages I compiled with Robotics System Toolbox Support Package and has a size of 44267 kB. Sometimes the error does not appear, but then Matlab gets REALLY slow after reading the bag, so no further computation is possible.
Whats wrong here?
Thank you for your help in advance!

6 comentarios

Would you mind post a few seconds of the bag file that you are using when you see this error?
Thanks so much
Hm, the bag has a size of 43,2 MB but I am only allowed to upload files as large as 5 MB. However, the error is not reproducable using a short version of that bag.
version: 2.0
duration: 34.5s
start: Oct 30 2015 15:09:54.99 (1446214194.99)
end: Oct 30 2015 15:10:29.51 (1446214229.51)
size: 43.2 MB
messages: 4170
compression: none [58/58 chunks]
types: int_rec/PreprocessingData [c18e16f7b634d51acea97ab620649596]
topics: int_rec/preprocessed_data 4170 msgs : int_rec/PreprocessingData
Hi Tobias,
Sorry that you are running into this problem. Depending on your MATLAB configuration and other running code, the Java heap space might be limited. This can lead to the error that you are describing when reading a lot of ROS messages into memory at the same time.
Have you tried increasing the Java heap memory that is at MATLAB's disposal? See this documentation page. The default value is 384 MB, but you might want to increase it to a larger value.
Alternatively, you could try loading only a subset of messages (the second argument to readMessages specifies the messages to read, e.g. 1:1000) or using the timeseries function to directly extract the numeric values without creating message objects.
Thanks
Thank you for your help! I tried using timeseries function and increasing the Java heap memory and both of your suggested solutions work! Using timeseries function reads the bag smoothly without having to increase the heap memory, while readMessages now works fine that I set the heap memory to 1GB.
Something I don´t understand is why another bag I have that is even larger and containing more messages reads smoothly using the readMessages function without having to increase the heap memory - but for me that´s OK for now ;)
I am glad to hear that this worked for you. I will post my workarounds as an answer and it would be great if you can "Accept this answer"
I am glad to hear that this worked for you. I will post my workarounds as an answer and it would be great if you can "Accept this answer"

Iniciar sesión para comentar.

 Respuesta aceptada

Depending on your MATLAB configuration and other running code, the Java heap space might be limited. This can lead to the error that you are describing when reading a lot of ROS messages into memory at the same time.
Have you tried increasing the Java heap memory that is at MATLAB's disposal? See this documentation page . The default value is 384 MB, but you might want to increase it to a larger value.
Alternatively, you could try loading only a subset of messages (the second argument to readMessages specifies the messages to read, e.g. 1:1000) or using the timeseries function to directly extract the numeric values without creating message objects.

Más respuestas (2)

On the Home tab, in the Environment section, click Preferences. Select MATLAB > General > Java Heap Memory. Select a Java heap size value using the slider or spin box. Note. ... Click OK. Restart MATLAB.
Since i had problem in using the timeseries and extracting the data, i wrote the following function
function [ time,images ] = getCameraFromBag( bag )
%getCameraFromBag Gives back the time and the images in a strucure vector
topic='/STEREO_CAM/STEREO_CAM_RAW_DATA' ;
[ts,~] = timeseries(select(bag,'Topic',topic));
time=ts.Time;
n_messages=length(time);
bagselect=select(bag,'Topic',topic);
images=[];
for i=1:n_messages
msgs = readMessages(bagselect,i);
images(i).left=readImage(msgs{1}.Left);
images(i).right=readImage(msgs{1}.Right);
end
end
reading one message at time limited the problem of memory. Cheers, Gianni.

Categorías

Más información sobre ROS Log Files and Transformations en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by