Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

Subject: Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

From: Nasser Abbasi

Date: 23 Jul, 2008 05:19:50

Message: 1 of 6

2007a, student version on windoz XP SP2.

I use GUIDE, and after sometime of using it, I notice it gets sluggish in
its response to editing and I see the following Java errors on the console:

"Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java
heap space"

I am not sure why it runs out of RAM so fast. as I have 4 GB of physical
RAM.

I did a google on the above and I see that others have seen this.

I wonder if there is any update on this problem that someone from Mathworks
or others can comment on.

Is this still a problem in later Matlab releases?

thanks,
Nasser

Subject: Exception in thread

From: Stefan

Date: 30 Jul, 2008 08:34:03

Message: 2 of 6

Dear Nasser,

I'm dealing with the same problems. And it seems, that noone
really knows something about the java heap memory. I never
got a clear response on this topic.

I found a small workaround to free some heap memory.

heapTotalMemory = java.lang.Runtime.getRuntime.totalMemory;
heapFreeMemory = java.lang.Runtime.getRuntime.freeMemory;
if(heapFreeMemory < (heapTotalMemory*0.01))
    java.lang.Runtime.getRuntime.gc;
end

I'm calling the java garbace collector if the free memory
drops below a certain limit.

Maybe this helps.
Keep me up to date if you get any news according to the java
heap memory.

Best regards,
  Stefan.

"Nasser Abbasi" <nma@12000.org> wrote in message
<Zbzhk.16026$mh5.2132@nlpi067.nbdc.sbc.com>...
> 2007a, student version on windoz XP SP2.
>
> I use GUIDE, and after sometime of using it, I notice it
gets sluggish in
> its response to editing and I see the following Java
errors on the console:
>
> "Exception in thread "AWT-EventQueue-0"
java.lang.OutOfMemoryError: Java
> heap space"
>
> I am not sure why it runs out of RAM so fast. as I have 4
GB of physical
> RAM.
>
> I did a google on the above and I see that others have
seen this.
>
> I wonder if there is any update on this problem that
someone from Mathworks
> or others can comment on.
>
> Is this still a problem in later Matlab releases?
>
> thanks,
> Nasser
>
>

Subject: Exception in thread

From: Juan Luis

Date: 21 Oct, 2008 09:57:01

Message: 3 of 6

I get the same error.

It is disgusting, because now I get this error when I execute a file that was working perfectly some days ago. Unfortunately, I had to format my HD and now I get this strange error.

I am a unexperienced user. How can I get this fixed? Thanks very much...

Subject: Exception in thread

From: Dave Brackett

Date: 21 Oct, 2008 13:32:01

Message: 4 of 6

"Juan Luis " <jlvalera@yahoo.es> wrote in message <gdk91d$b$1@fred.mathworks.com>...
> I get the same error.
>
> It is disgusting, because now I get this error when I execute a file that was working perfectly some days ago. Unfortunately, I had to format my HD and now I get this strange error.
>
> I am a unexperienced user. How can I get this fixed? Thanks very much...

have you tried increasing the maximum allowed heap space as explained in the instructions at this page:
http://www.mathworks.com/support/solutions/data/1-18I2C.html

it sorted my problem when I got this error.

Subject: Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

From: Joel

Date: 25 Mar, 2010 15:30:19

Message: 5 of 6

I have also run into some troubles with to little allocated memory for the java heap. The default max allocatalbe memory for the java heap in Matlab is 128Mb i think. You can change this by adding a file called
java.opts in $MATLABROOT/bin/$ARCH
If you want to change the max heap size to, for example 1024mb insert a line:
-Xmx2048m
in the java.opts file
I don't know how to unallocate java heap memory when used though...
BR
Joel

"Nasser Abbasi" <nma@12000.org> wrote in message <Zbzhk.16026$mh5.2132@nlpi067.nbdc.sbc.com>...
> 2007a, student version on windoz XP SP2.
>
> I use GUIDE, and after sometime of using it, I notice it gets sluggish in
> its response to editing and I see the following Java errors on the console:
>
> "Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java
> heap space"
>
> I am not sure why it runs out of RAM so fast. as I have 4 GB of physical
> RAM.
>
> I did a google on the above and I see that others have seen this.
>
> I wonder if there is any update on this problem that someone from Mathworks
> or others can comment on.
>
> Is this still a problem in later Matlab releases?
>
> thanks,
> Nasser
>
>

Subject: Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

From: john

Date: 3 Dec, 2012 17:11:11

Message: 6 of 6

The suggested solutions worked for me first time on 2011a
http://www.mathworks.co.uk/support/solutions/en/data/1-18I2C/

Many thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us