While saving a scene in the terrain editor, I got the following Heap Space error, and it looks like it also corrupted the j3o file so it can’t be loaded or opened anymore.
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
at java.io.OutputStream.write(OutputStream.java:75)
at com.jme3.export.binary.BinaryExporter.save(BinaryExporter.java:287)
at com.jme3.gde.core.assets.AssetDataObject.saveAsset(AssetDataObject.java:234)
at com.jme3.gde.core.assets.SpatialAssetDataObject.saveAsset(SpatialAssetDataObject.java:111)
at com.jme3.gde.core.assets.AssetData.saveAsset(AssetData.java:140)
at com.jme3.gde.core.scene.SceneApplication.checkSave(SceneApplication.java:509)
at com.jme3.gde.core.scene.SceneApplication.access$1400(SceneApplication.java:91)
at com.jme3.gde.core.scene.SceneApplication$5.run(SceneApplication.java:459)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Thankfully I was editing scenes with both the SDK and JMB today, though - I was able to immediately recover the file since I had a non-corrupted version opened in JMB from a few minutes prior to the error.
I forgot that I haven’t upped the heap space setting in the SDK config file since I upgraded versions, so that should solve the problem from happening again anytime soon.
But in the case that I make this mistake and have a file become corrupted again, is there any way to fix / restore a corrupted j3o scene aside from frequently backing up my assets?