Getting Java OutOfMemoryError, when added some linked nodes in sceneComposer

My Scene was running perfectly fine until I added some trees in sceneComposer. The application complains about java out of memory error. I have added -Xmx2g option but it didn’t help. Now the scene doesn’t even load in sceneComposer. Here is the stack trace.

java.lang.OutOfMemoryError: Java heap space
at com.jme3.export.binary.BinaryImporter.readString(BinaryImporter.java:292)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:181)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:125)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:109)
at com.jme3.scene.AssetLinkNode.read(AssetLinkNode.java:162)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:344)
at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:483)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:471)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:587)
at com.jme3.scene.Node.read(Node.java:599)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:344)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:242)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:125)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:109)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:378)
at mygame.Main.simpleInitApp(Main.java:28)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

Looks like your scene is simply too big.

My scene only consist of terrain and 1 extra texture. The disk space of myterrain.j3o is 1.40 MB and myterrain.j3odata is 71bytes. It used to work fine. But when I linked 3 trees ( of vertices 2K each ) , it goes out of memory.

How big is the tree model?

The disk space of tree.j3o is 46.2 KB and has around 2K vertices. I have used rotate feature of sceneComposer to rotate this tree in scene.

did you add that xmx configuration in the actual jmonkeyplatform.conf file or as a command line parameter?

I have added through Project->RightClick->Project Properties->Run->VM Options -Xmx2g .

for viewing it in the scene composer you need to increase the heap space of the sdk itself: https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:increasing_heap_memory

for increasing the heap size for your actual game that is the correct way to increase it afaik.

inside of your program you could do Runtime.getRuntime().getMaxMemory(); to verify that it actually has 2 gigabytes of memory.