Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

I have written a code and I run it a lot but suddenly I got an OutOfMemoryError:

  Exception in thread "main" java.lang.OutOfMemoryError: Java heap space         at javax.media.j3d.BoundingBox.<init>(BoundingBox.java:86)         at javax.media.j3d.NodeRetained.<init>(NodeRetained.java:198)         at javax.media.j3d.LeafRetained.<init>(LeafRetained.java:40)         at javax.media.j3d.LightRetained.<init>(LightRetained.java:44)         at javax.media.j3d.DirectionalLightRetained.<init>(DirectionalLightRetained.java:50)         at javax.media.j3d.DirectionalLight.createRetained(DirectionalLight.java:116)         at javax.media.j3d.SceneGraphObject.<init>(SceneGraphObject.java:119)         at javax.media.j3d.Node.<init>(Node.java:178)         at javax.media.j3d.Leaf.<init>(Leaf.java:50)         at javax.media.j3d.Light.<init>(Light.java:270)         at javax.media.j3d.DirectionalLight.<init>(DirectionalLight.java:87) 
like image 408
Johanna Avatar asked Mar 04 '10 18:03

Johanna


People also ask

How do I fix this exception in thread main Java Lang OutOfMemoryError Java heap space?

As explained in the above paragraph this OutOfMemory error in java comes when the Permanent generation of heap is filled up. To fix this OutOfMemoryError in Java, you need to increase the heap size of the Perm space by using the JVM option "-XX: MaxPermSize".

What causes Java heap space error?

Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further.

How do I fix a heap space error?

The java. lang. OutOfMemoryError: Java heap space error occurs when it attempts to add more data into the heap space area, but there is not enough room for it. The solution to fix this problem is to increase the heap space(Default value maybe 128 MB).

What does Java Lang OutOfMemoryError heap space?

lang. OutOfMemoryError is a runtime error in Java which occurs when the Java Virtual Machine (JVM) is unable to allocate an object due to insufficient space in the Java heap. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java. lang. OutOfMemoryError .


1 Answers

Well, it's fairly self-explanatory: you've run out of memory.

You may want to try starting it with more memory, using the -Xmx flag, e.g.

java -Xmx2048m [whatever you'd have written before] 

This will use up to 2 gigs of memory.

See the non-standard options list for more details.

like image 139
Jon Skeet Avatar answered Oct 06 '22 00:10

Jon Skeet