ds-pokemon-hacking / CTRMap-CE

CTRMap Community Edition, an extensible level editor for Pokémon Black/White/Black 2/White 2.
GNU General Public License v3.0
16 stars 3 forks source link

Out of memory error occuring on one machine but not another when building ROM #8

Closed BromBromBromley closed 11 months ago

BromBromBromley commented 11 months ago

For some reason, when I try exporting a ROM using the CE core released on August 20 and the CTRMapV plugin from June 8 on my laptop instead of my desktop, I get the following error.

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at xstandard.io.base.impl.access.MemoryStream.toByteArray(MemoryStream.java:46)
        at xstandard.fs.accessors.MemoryFile$1.close(MemoryFile.java:135)
        at xstandard.fs.FSUtil.writeBytesToStream(FSUtil.java:510)
        at xstandard.fs.FSUtil.writeBytesToFile(FSUtil.java:367)
        at xstandard.fs.FSUtil.copy(FSUtil.java:208)
        at ctrmap.formats.ntr.narc.DirectNARC.setData(DirectNARC.java:257)
        at WSFSPlugin.writeToArcFile(WSFSPlugin.java:56)
        at ctrmap.editor.system.workspace.WSFS.writeToArcFile(WSFS.java:182)
        at CTRMapPlugin.loadVFS(CTRMapPlugin.java:94)
        at CTRMapPlugin.loadVFS(CTRMapPlugin.java:100)
        at CTRMapPlugin.loadVFS(CTRMapPlugin.java:100)
        at CTRMapPlugin.loadVFS(CTRMapPlugin.java:100)
        at CTRMapPlugin.loadVFS(CTRMapPlugin.java:100)
        at CTRMapPlugin.lambda$registUI$0(CTRMapPlugin.java:129)
        at CTRMapPlugin$$Lambda$109/8112115.actionPerformed(Unknown Source)
        at ctrmap.editor.CTRMapUIManager$1.actionPerformed(CTRMapUIManager.java:35)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(Unknown Source)
        at javax.swing.SwingUtilities.notifyAction(Unknown Source)
        at javax.swing.JComponent.processKeyBinding(Unknown Source)
        at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(Unknown Source)
        at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(Unknown Source)
        at javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(Unknown Source)
        at javax.swing.JMenuBar.processKeyBinding(Unknown Source)
        at javax.swing.KeyboardManager.fireBinding(Unknown Source)
        at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)

Here are my laptop's specs:

Processor   11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz   2.30 GHz
Installed RAM   16.0 GB (15.7 GB usable)
Device ID   7F203EB1-C8F5-4692-87DE-1B9B44CFD4FC
Product ID  00325-80000-00000-AAOEM
System type 64-bit operating system, x64-based processor
Pen and touch   Pen support

The weird thing is that it is able to build a clean ROM OK and also a clean ROM with PMC installed plus patches, too, so I think it has something to do with my VFS in some way? The only difference between my testing project and my actual project is the assets folder (vfs/data/a) and even then it seems to be a few problem NARCs like a008 and a014 from what I've been testing so far. I'm really at a loss for what it is given that I've been able to build OK on my desktop.

HelloOO7 commented 11 months ago

Could you post the output of java -XX:+PrintFlagsFinal -version of both machines?

BromBromBromley commented 11 months ago

Yeah, sure.

Here's the log from my desktop:

https://pastebin.com/VVkxDxCE

Here are the flags for my laptop:

https://pastebin.com/6ciZaujT

HelloOO7 commented 11 months ago

The maximum heap size on your laptop seems to be around 256M (which is not very much), whereas your desktop uses something closer to 2GB. That's a bit odd since most of the time, Java automatically sets it to like 1/4 of your total RAM, nonetheless, you can always increase it manually with a command line switch, along the lines of -Xmx2048M for 2GB etc.

Let me know if that fixes the issue.

BromBromBromley commented 11 months ago

When trying to use 2048MB for it on my laptop, it says this:

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

I noticed there was a version difference between my desktop version and my laptop version of Java as well. I'm partially inclined to think that I might have the 32-bit version of Java on my desktop given that programs that aren't large address aware are capped at 2GB. I was able to use 1024MB all right at least, but I will try looking into the Java mismatch.

BromBromBromley commented 11 months ago

OK, that seems to have been the issue. Installing a 64-bit of Java seemed to have fixed this issue. Thanks for the help!