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)
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".
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.
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).
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 .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With