Page 3 of 5

Re: java heap size error

PostPosted: 12 Feb 2010, 01:01
by DennisBergkamp
Try running it from there instead. So:

cd/Applications/mtgforge0209
(now typing 'pwd' should show that you're in that location: "/Applications/mtgforge0209")
java -jar run-forge.jar -Xmx512m Gui_NewGame

It looks like your java can't find the forge.properties file, I'm guessing that happens because you're running it from a different location.

EDIT: or yes, what Chris says, another way would be to copy over the forge.properties file into your home directory.

Re: java heap size error

PostPosted: 12 Feb 2010, 01:30
by Chris H.
DennisBergkamp wrote:Try running it from there instead. So:

cd/Applications/mtgforge0209
(now typing 'pwd' should show that you're in that location: "/Applications/mtgforge0209")
java -jar run-forge.jar -Xmx512m Gui_NewGame

It looks like your java can't find the forge.properties file, I'm guessing that happens because you're running it from a different location.

EDIT: or yes, what Chris says, another way would be to copy over the forge.properties file into your home directory.
`
It looks like a space is needed between the cd and the path. I just tried it and it works. I guess this could be turned into an Apple script?

Re: java heap size error

PostPosted: 12 Feb 2010, 04:38
by Almost_Clever
nantuko84 wrote:probably that's because of using .exe
try the same with jar file, just type this in command line

Code: Select all
java -jar run-forge.jar -Xmx512m Gui_NewGame
This worked well for me. Before I did this, I could not finish a single quest or draft match using HQ images without getting a java heap size error, but I just played a number of matches with no apparent slowdowns at all.

Chris H. wrote:Yes, you are getting closer. I tried and got the same response. I used the help system and found a "pwd" command which will return your working directory name. In our case it displays the user's home directory.

When we start run-forge.jar with this method, the jar file is looking for the data files in our home directory. We must first set the working directory to the correct path. You may want to try the help system and see if you can find the right command to change the working directory name path. :roll:
I run Forge with a batch file:
Code: Select all
cd "c:\Users\terry\MTG Forge\beta\"
java -jar run-forge.jar -Xmx512m Gui_NewGame
'run-forge.jar
exit

Re: java heap size error

PostPosted: 12 Feb 2010, 06:00
by LutherBlissett
Ok, it loads now, I'll give it a workout when I get home.

Is it possible to create a batch file for OS X?

If I was running this on Windows it would be easy ;)

Re: java heap size error

PostPosted: 12 Feb 2010, 07:03
by silly freak
batch files are windows, the unix equivalent is a shell script. Under linux (i hope it works the same on mac, if a mac user could confirm this, it would be perfect), I use a shell script that looks roughly like this.

Code: Select all
#! /bin/bash
cd <<location of forge>>
java -jar run-forge.jar -Xmx512m Gui_NewGame
name it something like "run-forge.sh", be sure to make it executable, for example with command line:
Code: Select all
chmod +x run-forge.sh
after that, you should be able to start forge by double click

Re: java heap size error

PostPosted: 12 Feb 2010, 08:02
by LutherBlissett
silly freak wrote:
name it something like "run-forge.sh", be sure to make it executable, for example with command line:
Code: Select all
chmod +x run-forge.sh
after that, you should be able to start forge by double click
Thanks.
I did all that but Textpad refused to save it as .sh and when I renamed it, it still just opens in Textpad.
Is there another program I should be using?

*EDIT* disregard, I got it working... now to see how long I can play on High Quality.

Thanks for all the help BTW! Great to learn new things in the pursuit of fun! ;)

Re: java heap size error

PostPosted: 12 Feb 2010, 08:44
by LutherBlissett
Damn, turn#5 on Easy game:

An error has occured. You can copy/paste this message or save it to a file.
Please report this, plus what you tried to do, to:
viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
mtgerror@yahoo.com


Java heap space


Version:
Forge -- official beta: $Date: 2010-02-04 04:57:00 -0600 (Thu, 04 Feb 2010) $, SVN revision: $Revision: 325 $

Detailed error trace:
java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:317)
at javax.imageio.ImageIO.read(ImageIO.java:1416)
at javax.imageio.ImageIO.read(ImageIO.java:1322)
at arcane.ui.util.ImageUtil.getImage(ImageUtil.java:15)
at forge.GuiDisplay3.updateCardDetailPicture(GuiDisplay3.java:667)
at forge.GuiDisplayUtil$1.mouseMoved(GuiDisplayUtil.java:169)
at java.awt.Component.processMouseMotionEvent(Component.java:5647)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3153)
at java.awt.Component.processEvent(Component.java:5371)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3949)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Re: java heap size error

PostPosted: 12 Feb 2010, 08:57
by nantuko84
I just wonder why you still haven't fixed this issue with HQ images.
It's clear (at least for me) that the bug is most critical and should have highest priority. Moreover so many programmers, even not from Forge team, posted here their advices how to reproduce\fix that. Playing with memory parameters does nothing until you have bug in your code ;(

Re: java heap size error

PostPosted: 12 Feb 2010, 09:07
by LutherBlissett
I set the Xmx to 1g and played through a fairly short game - then got the following Heap Space error when I clicked "Continue Match":

java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.<init>(BufferedImage.java:317)
at javax.imageio.ImageIO.read(ImageIO.java:1416)
at javax.imageio.ImageIO.read(ImageIO.java:1286)
at forge.ImageCache.getImage(ImageCache.java:78)
at forge.GuiDisplayUtil.getCardPanel(GuiDisplayUtil.java:48)
at forge.GuiDisplayUtil.getCardPanel(GuiDisplayUtil.java:42)
at forge.GuiDisplay3$20.update(GuiDisplay3.java:806)
at java.util.Observable.notifyObservers(Observable.java:142)
at java.util.Observable.notifyObservers(Observable.java:98)
at forge.MyObservable.updateObservers(MyObservable.java:10)
at forge.DefaultPlayerZone.update(DefaultPlayerZone.java:111)
at forge.DefaultPlayerZone.add(DefaultPlayerZone.java:41)
at forge.GameAction.drawCard(GameAction.java:841)
at forge.GameAction.newGame(GameAction.java:1043)
at forge.Gui_WinLose.continueButton_actionPerformed(Gui_WinLose.java:160)
at forge.Gui_WinLose$1.actionPerformed(Gui_WinLose.java:104)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)

Re: java heap size error

PostPosted: 12 Feb 2010, 10:05
by nantuko84
didn't take too much time to find a bug
it was really fun ;) don't create object instances inside themselves, and try to use singleton patterns for such memory-heavy objects (like PicturePanel, GUI_PictureHQ)

take into account that tested in DeckEditor only, but at least there it works now.
use case to reproduce for r370:
0. in task manager I had javaw.eve 58M
1. download at least one HQ image, e.g. Swamp
2. open deck editor
3. find swamp (please implement searching by name, it was so pain to search for it among > 2000 cards)
4. move mouse to image panel, it will be enlarged as it is HQ image
5. go to neighbor card, then back to Swamp - repeat this ~50 times

in task manager you'll see javaw.eve > 100 Mb and OutOfMemoryException in Forge

the same with lq pictures, but not so critical - 0,5-1 Mb after 100 calls

and here the fix that just removes creating objects and make one object instance without disposing but updating image only
should be tested carefully
and please inform if u have OutOfMemory again in the game

p.s. patch should be applied to svn\src\src

Re: java heap size error

PostPosted: 12 Feb 2010, 11:59
by Chris H.
silly freak wrote:batch files are windows, the unix equivalent is a shell script. Under linux (i hope it works the same on mac, if a mac user could confirm this, it would be perfect), I use a shell script that looks roughly like this.

Code: Select all
#! /bin/bash
cd <<location of forge>>
java -jar run-forge.jar -Xmx512m Gui_NewGame
name it something like "run-forge.sh", be sure to make it executable, for example with command line:
Code: Select all
chmod +x run-forge.sh
after that, you should be able to start forge by double click
`
I tried it on my Mac. It did not launch forge when I double clicked on the run-forge.sh file, instead it launched NetBeans. :rolleyes:

There is an app in the utilities folder named AppleScript Editor. I have never used it before but suspect that it could be used to create a script that would automate the process.

Re: java heap size error

PostPosted: 12 Feb 2010, 18:15
by DennisBergkamp
nantuko84 wrote:I just wonder why you still haven't fixed this issue with HQ images.
It's clear (at least for me) that the bug is most critical and should have highest priority. Moreover so many programmers, even not from Forge team, posted here their advices how to reproduce\fix that. Playing with memory parameters does nothing until you have bug in your code ;(
Nantuko,

I don't think there's a bug anymore (in the deck editor, yes there still was - thanks for fixing that by the way!). But all of the problems people are having, are in in-game....
What I did is this (actually, I didn't do that much since I just used the code Snacko posted) :

1. If the image that's currently being shown is the same as the image of the card being "hovered into", do nothing.
2. Enabled caching of the large images on the right hand side.
2. Caching uses Google Collections, allowing SoftReferences (or WeakReferences? ) to be used, which supposedly makes them more easily collectable by the Garbage Collector.

Maybe I'm wrong, but I don't think there's a memory leak currently in the in-game part of Forge.
What I think is the issue, is that using HQ images will take up a fairly substantial amount of memory no matter what (I hit 200 - 300 megs after a few games, but this is just due to the fact that there's a lot of different images being used). Having said that, I've NEVER run into a Heap Space error myself using forge, and my JVM memory settings are set to 512 max.

So I don't know, playing around with the memory settings seemed to be the next logical thing to do, especially when people are reporting crashes within minutes of playing a match. That really shouldn't happen, since these cases reported used computers oftentimes with 2GB+ RAM.

By the way, we do have a way to search for cards (either by name or card text - just click Filter in the deck editor).

Re: java heap size error

PostPosted: 12 Feb 2010, 23:22
by LutherBlissett
Chris H. wrote:`
I tried it on my Mac. It did not launch forge when I double clicked on the run-forge.sh file, instead it launched NetBeans. :rolleyes:

There is an app in the utilities folder named AppleScript Editor. I have never used it before but suspect that it could be used to create a script that would automate the process.
with Textpad you need to select the menu item (Convert to Simple Text) and then you can save it as a unicode txt file.
Then you need to Right/Click and set it to load in Terminal.app at all times.

Yr AppleScript Editor sounds the business though.

Re: java heap size error

PostPosted: 12 Feb 2010, 23:52
by Almost_Clever
Almost_Clever wrote:This worked well for me. Before I did this, I could not finish a single quest or draft match using HQ images without getting a java heap size error, but I just played a number of matches with no apparent slowdowns at all.
Sorry, it doesn't really seem to be working. If I reboot, I might be able to get a match or two in before the java heap error, but sometimes I can't even finish a single game...

Re: java heap size error

PostPosted: 13 Feb 2010, 00:08
by LutherBlissett
DennisBergkamp wrote:1. If the image that's currently being shown is the same as the image of the card being "hovered into", do nothing.
2. Enabled caching of the large images on the right hand side.
2. Caching uses Google Collections, allowing SoftReferences (or WeakReferences? ) to be used, which supposedly makes them more easily collectable by the Garbage Collector.

Maybe I'm wrong, but I don't think there's a memory leak currently in the in-game part of Forge.
It's a little variable but i'm getting the Java Heap Space error after about 10mins of play usually.
Thought I'd do a little detective work: counting the number of cards played at the point of the error (including cards in the Graveyard etc...)
First game: 29 cards played, game ended, no error
Second game: 9 cards played, error
So 38 cards until an error. Each card is on average about 150kb * 38 = 5700kb or 5.56mb
Doesn't make much sense that this would cause a Java Heap Error, even if we double that amount to include the thumbnail size versions, unless:
1) the java heap space is not being set at 512mb (is there a way to get the JVM to return this info?)
2) each time an image is moused over it takes more memory and does not give it back (no garbage collection) which could be a problem since in mousing across a hand to find a card I can trigger multiple cards in the display window.