Corrupted j3o file

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(
	at com.jme3.gde.core.assets.AssetDataObject.saveAsset(
	at com.jme3.gde.core.assets.SpatialAssetDataObject.saveAsset(
	at com.jme3.gde.core.assets.AssetData.saveAsset(
	at com.jme3.gde.core.scene.SceneApplication.checkSave(
	at com.jme3.gde.core.scene.SceneApplication.access$1400(
	at com.jme3.gde.core.scene.SceneApplication$
	at java.awt.event.InvocationEvent.dispatch(
	at java.awt.EventQueue.dispatchEventImpl(
	at java.awt.EventQueue.access$500(
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue.dispatchEvent(
	at org.netbeans.core.TimableEventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(

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?

How does JMB handle this type of potential problem?

I believe JMB also corrupts the file if a heap space error occurs while saving, although it only ever happened to me once. Last week I had a file get corrupted the same way in JMB after I had been using the editor for a long time and had a lot of scenes open. But I think I was also playing around with the new model spawner tool and set a larger radius and brush power than I should have set while using the batch mode .

So it seems like a problem that occurs anytime an OutOfMemory error occurs in the middle of saving a file.

Wonder if its possible to write it to a temp folder first and then move at end of write process?

That sounds like it would solve the problem, if possible.

But I guess I also don’t know very much about how the current write process works for the j3o save to say whether or not that would be as easy of a solution as it sounds.

Unfortunately, until someone submits a patch to write to a temp file and rename back when done, the only solution would be to pull the last version back from source control or backups.

Sometimes that 20 minutes or an hour worth of changes can be pretty significant, though.

I try to save a scene to a temp file before updating “opened” file.