Page 1 of 1

Unhandled exception - out of memory

Posted: Sun Jan 08, 2012 3:04 pm
by Kragdob
I don't know if this is related to my computer only but anyway even if this is not brand new such things shouldn't happen.

My game hangs ocasionally with following error:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Unknown Source)
        at java.awt.EventQueue.initDispatchThread(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
I cannot replicate it at ease but it happens some and then. Usually when I switch to large view (but also during other actions). It got better when I started to switch Firefox off but still happens occasionally. Is there a possibility to add some try/catch so games does not hang after you spent 45 minutes on units movement?

Recently this 'event' was preceded by this one (still could play though):

Code: Select all

Exception occurred during event dispatching:
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Unknown Source)
        at sun.awt.image.ImageFetcher$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.image.ImageFetcher.createFetchers(Unknown Source)
        at sun.awt.image.ImageFetcher.add(Unknown Source)
        at sun.awt.image.InputStreamImageSource.startProduction(Unknown Source)
        at sun.awt.image.InputStreamImageSource.addConsumer(Unknown Source)
        at sun.awt.image.InputStreamImageSource.startProduction(Unknown Source)
        at sun.awt.image.ImageRepresentation.startProduction(Unknown Source)
        at sun.awt.image.ImageRepresentation.drawToBufImage(Unknown Source)
        at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
        at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
        at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
        at gui.MapCanvas.drawPResources(MapCanvas.java:831)
        at gui.MapCanvas.render(MapCanvas.java:2088)
        at gui.MapCanvas.paintComponent(MapCanvas.java:2023)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
        at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
        at javax.swing.JComponent._paintImmediately(Unknown Source)
        at javax.swing.JComponent.paintImmediately(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.Dialog$1.run(Unknown Source)
        at java.awt.Dialog$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Dialog.show(Unknown Source)
        at java.awt.Component.show(Unknown Source)
        at java.awt.Component.setVisible(Unknown Source)
        at gui.WarWindow.showBeginTurnDialog(WarWindow.java:506)
        at game.Game.startGame(Game.java:22959)
        at gui.MainMenu.loadGame(MainMenu.java:414)
        at gui.GameModeSelection2.jButton2_actionPerformed(GameModeSelection2.java:229)
        at gui.GameModeSelection2_jButton2_actionAdapter.actionPerformed(GameModeSelection2.java:298)
        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.JToggleButton$ToggleButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

Posted: Sun Jan 08, 2012 3:31 pm
by rkr1958
This happens to me too occasionally. The thing I do, which is the only thing I know to do, is to shut the game down (kill it with task manager) and restart. If this continues to happen too frequently for a particular game turn (or in general) I will also shut down other applications (e.g., browser, email).

Posted: Mon Jan 09, 2012 9:21 am
by Kragdob
rkr1958 wrote:This happens to me too occasionally. The thing I do, which is the only thing I know to do, is to shut the game down (kill it with task manager) and restart. If this continues to happen too frequently for a particular game turn (or in general) I will also shut down other applications (e.g., browser, email).
I do the same but it happens quite often - is it possible to trace the place where it happens?

Posted: Mon Jan 09, 2012 12:13 pm
by rkr1958
Kragdob wrote:
rkr1958 wrote:This happens to me too occasionally. The thing I do, which is the only thing I know to do, is to shut the game down (kill it with task manager) and restart. If this continues to happen too frequently for a particular game turn (or in general) I will also shut down other applications (e.g., browser, email).
I do the same but it happens quite often - is it possible to trace the place where it happens?
Realistically, that would require some sort of memory monitoring program (not free) and a significant bit of effort. Both beyond the means of a fan based dev team I'm afraid.

Posted: Mon Jan 09, 2012 7:59 pm
by Peter Stauffenberg
The game never crashes on me, but I have 12 GB of RAM in my computer. So I can't recreate this error.