MegaMek / megamek

MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight using giant robots, tanks, and/or infantry on a hex-based map.
http://www.megamek.org
GNU General Public License v2.0
295 stars 283 forks source link

Megamek freeze and application auto shutdown #2454

Open JonhyBurner opened 3 years ago

JonhyBurner commented 3 years ago

MekHQ 47.14 Java 1.8.0_271 Windows 10

I was in the middle of a base attack scenario, with a larger number of units than usual. At turn 8, the game freezes just before the physical attack phase. I decided to wait it out, in the past when this happened, sometimes the game resumes after spending a little while with low CPU usage.

Instead, after about 5 minutes or so, as I clicked the Megamek window, the game starts hogging CPU again, like it was processing the turn and then promptly shuts down! Never had that happen before. The java process was still up on task manager, using the same amount of memory, but no application in sight. Digging into the resource monitor gave me: "One or more threads are waiting to finish" on the java exe.

Reloaded the campaign and the scenario and played through the round with no problems.

megameklog.zip mekhqlog.zip Campaign.cpnx.gz Closest save: autosave.sav.gz customs.zip (not needed for the scenario, just the campaign) Player Name: Grand Campaign of Lisbon

HammerGS commented 3 years ago

From the log -

Exception in thread "D3D Screen Updater" Exception in thread "Client Connection, Player Base Civilian Units" Exception in thread "Packet Pump" java.lang.OutOfMemoryError: Java heap space
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getDeclaredMethod(Unknown Source)

Also lots of references to:

03:18:22,815 ERROR [megamek.common.Board] {AWT-EventQueue-0} 
updateBuildings(), line 1533 : Could not find a match for Medium Standard Building #2199 to update.

Have you allocated more memory to Megamek in the MegaMek.l4j.ini file?

rjhancock commented 3 years ago

And update from Java 8 to OpenJDK 11 64-bit if possible. If running the 32bit version of Java 8, more memory won't help as it wont be able to access it.

JonhyBurner commented 3 years ago

@HammerGS Yeah, I've been looking around and found out the MegaMek.l4j.ini file only had 1024MB, so the ~1300MB being used by Java were way beyond that, and that may have been the culprit.

And I do have Java 64, so now that I changed the .ini file to 2048MB, I should have no more problems. Shouldn't that value be changed, or users be encouraged to do it on the "RUNNING MEGAMEK" section?

rjhancock commented 3 years ago

I think the l4j file is only loaded when running MegaMek as the EXE. When you load it via the console directly java -jar MegaMek.jar the memory limit doesn't seem to apply beyond what Java can access.

I may be wrong about that though.

And if you have the memory, I'd say bump it up to 4096MB.

JonhyBurner commented 3 years ago

Well, the freezing happened again at the Megamek end of battle report. Couldn't click on done to finish and go back to MekHQ, but oddly enough, I could save (but when loaded, the save had a lot of data missing from the enemy reinforcements). Force-closing the game and reloading the previous save allowed me to go to resolution in MekHQ just fine.

It was a memory issue again, since the memory use was at ~2200MB. I've increased the memory allowance to 3GB on the .ini file (can't afford 4GB). We'll see if the next big battle goes more smoothly. I had no idea the memory use skyrocketed like that for bigger battles. Is it the map size or the unit amount that causes it?

HammerGS commented 3 years ago

How large are the battles? Size of the map? Logs from the latest issues?

JonhyBurner commented 3 years ago

The battle was on a 50x70 light-urban map with 20 allied units against 40 enemy units. No logs, but they had a lot of these kind of messages:

updateBuildings(), line 1533 : Could not find a match for Medium Standard Building #2199 to update

so I suppose the issue was the same, lack of allocated memory.

This is the save I made at the freeze point DamagedSave.sav.gz

HammerGS commented 3 years ago

When I try to load the damage save, it won't load and here is the log.

Security framework of XStream not explicitly initialized, using predefined black list on your own risk.
15:31:34,155 ERROR [megamek.server.Server] {AWT-EventQueue-0} 
loadGame(), line 1326 : Unable to load file: D:\MegaMek_Workspace\megamek\megamek\savegames\DamagedSave.sav.gz
com.thoughtworks.xstream.converters.ConversionException: Failed calling method
---- Debugging information ----
message             : Failed calling method
cause-exception     : com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException
cause-message       : No such field megamek.common.BipedMech.hasExternalSpotlight
method              : java.util.concurrent.CopyOnWriteArrayList.readObject()
class               : java.util.concurrent.CopyOnWriteArrayList
required-type       : java.util.concurrent.CopyOnWriteArrayList
converter-type      : com.thoughtworks.xstream.converters.reflection.SerializableConverter
line number         : 67344
class[1]            : megamek.common.Game
required-type[1]    : megamek.common.Game
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version             : 1.4.14
-------------------------------
    at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:136)
    at com.thoughtworks.xstream.converters.reflection.SerializableConverter.doUnmarshal(SerializableConverter.java:443)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1404)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1383)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1277)
    at megamek.server.Server.loadGame(Server.java:1324)
    at megamek.server.Server.loadGame(Server.java:1304)
    at megamek.client.ui.swing.MegaMekGUI.loadGame(MegaMekGUI.java:559)
    at megamek.client.ui.swing.MegaMekGUI.lambda$0(MegaMekGUI.java:982)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6539)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at megamek.client.ui.swing.widget.MegamekButton.processMouseEvent(MegamekButton.java:243)
    at java.awt.Component.processEvent(Component.java:6304)
    at java.awt.Container.processEvent(Container.java:2239)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2297)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
    at java.awt.Container.dispatchEventImpl(Container.java:2283)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    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:74)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    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)
Caused by: com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field megamek.common.BipedMech.hasExternalSpotlight
---- Debugging information ----
message             : No such field megamek.common.BipedMech.hasExternalSpotlight
field               : hasExternalSpotlight
class               : megamek.common.BipedMech
required-type       : megamek.common.BipedMech
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 67344
-------------------------------
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.handleUnknownField(AbstractReflectionConverter.java:520)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:371)
    at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
    at com.thoughtworks.xstream.converters.reflection.SerializableConverter$2.readFromStream(SerializableConverter.java:325)
    at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:123)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:473)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:440)
    at java.util.concurrent.CopyOnWriteArrayList.readObject(CopyOnWriteArrayList.java:1002)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.thoughtworks.xstream.core.util.SerializationMembers.callReadObject(SerializationMembers.java:132)
    ... 58 more

megameklog.txt

JonhyBurner commented 3 years ago

That's strange, I can load the save just fine from MekHQ and even go to the resolution screen, with the mentioned missing reinforcements.