Memory Leak
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
45 posts
• Page 2 of 3 • 1, 2, 3
Re: Memory Leak
by silly freak » 11 Jan 2010, 06:54
did you repeat with the same image or show different ones?
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: Memory Leak
by DennisBergkamp » 11 Jan 2010, 15:09
Ah, just a regular game, with different images.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by silly freak » 11 Jan 2010, 16:23
with different images, it's clear that memory grows. important is that a single image is reused when shown repeatedly:
nantuko84 wrote:here are the results of testing:
1. without any images:
I played 5 games starting with 76 Mb in task manager
once 5th was started, I had 78 Mb allocated that means no memory leak in the program
2. I've downloaded some images
started a new game (again with about 76 Mb allocated)
all cards were text except one (Nevinnyral's Disk, but it doesn't matter)
I put mouse over the card with image so it was displayed at the right, then enlarge it putting mouse cursor over image.
I repeated this 20 times and now I had 122 Mb allocated.
when I started a next game, and it had already 121 Mb allocated instead of starting 76 Mb - so here is the source of your memory leak
regards
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: Memory Leak
by mtgrares » 11 Jan 2010, 20:41
At the very least, using the higher quality HQ card pictures will cause some computers run out of memory because the card pictures are bigger.
Good programming, which is what DennisBergkamp is trying to do, will allow Forge to use the least amount of memory possible. (Phantom and "weak references" are useful if you want to keep objects that take up a lot of memory. "Weak references" tell the computer to release the object if the computer needs it but otherwise keep the object alive.)
One good question would be, "How much memory is used by the Java Virtual Machine to display 10-20 HQ images?" This number would be a good "base" requirement.
Good programming, which is what DennisBergkamp is trying to do, will allow Forge to use the least amount of memory possible. (Phantom and "weak references" are useful if you want to keep objects that take up a lot of memory. "Weak references" tell the computer to release the object if the computer needs it but otherwise keep the object alive.)
One good question would be, "How much memory is used by the Java Virtual Machine to display 10-20 HQ images?" This number would be a good "base" requirement.
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: Memory Leak
by DennisBergkamp » 11 Jan 2010, 22:15
"Trying to" 
But I think images are cached correctly now, and if I hover over a single image a bunch of times, the memory will not increase

Yes, however, when I start a new game, memory is still not freed up. I mean, I don't know, maybe stuff will automatically get freed once my computer's running low on memory...with different images, it's clear that memory grows. important is that a single image is reused when shown repeatedly:
But I think images are cached correctly now, and if I hover over a single image a bunch of times, the memory will not increase

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by frwololo » 12 Jan 2010, 04:35
I can give a basic answer for that.mtgrares wrote:One good question would be, "How much memory is used by the Java Virtual Machine to display 10-20 HQ images?" This number would be a good "base" requirement.
Assuming you involve transparency, an image will be stored with 32 bits (4bytes) per pixel.
Clever conversions can change that into 16 bits (2bytes) per pixel. I'm assuming Java doesn't care and stores the textures as 32bpp but I might be wrong.
680 x 480 @ 32bpp =~ 1.3 MB per picture
The other pieces of data (the actual JPanel object, etc...) are very small compared to the actual image and do not need to be taken into account for the computation.
When dealing with limited memory (such as what we do on the PSP), you also have to take into account the memory required for decompressing the image and "optimizing" the texture, but through java on a PC this is probably done behind the hoods and does not need to be taken into account. (However in Wagic, during the decompression, we need more than twice the amount of memory required to store the texture, so on a limited device it is important to take that into account)
Last edited by frwololo on 14 Jan 2010, 05:06, edited 1 time in total.
Re: Memory Leak
by Chris H. » 13 Jan 2010, 14:08
I updated my local SVN copy to r269. I went into the Deck Editor and scrolled down the list of cards while hovering my mouse pointer over the jpg picture to have the larger HQ picture displayed. It took awhile, but I got an exception error.
And the stack report
- Code: Select all
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:
http://www.slightlymagic.net/forum/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: 10/01/01, SVN revision: 269
Detailed error trace:
java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:59)
at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:397)
at java.awt.image.Raster.createWritableRaster(Raster.java:938)
at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1056)
at javax.imageio.ImageReader.getDestination(ImageReader.java:2879)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:925)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:897)
at javax.imageio.ImageIO.read(ImageIO.java:1422)
at javax.imageio.ImageIO.read(ImageIO.java:1282)
at forge.GuiDisplayUtil.getPictureHQwidth(GuiDisplayUtil.java:476)
at forge.Gui_DeckEditor$CustomListener.mouseEntered(Gui_DeckEditor.java:877)
at java.awt.Component.processMouseEvent(Component.java:6357)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
at java.awt.Component.processEvent(Component.java:6113)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4714)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4407)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4264)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
And the stack report
- Code: Select all
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:
http://www.slightlymagic.net/forum/viewforum.php?f=26
If you don't want to register an account, you can mail it directly to
mtgerror@yahoo.com
You requested a full error report
Version:
Forge -- official beta: 10/01/01, SVN revision: 269
Detailed error trace:
Java2D Disposer (12):
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
sun.java2d.Disposer.run(Disposer.java:125)
java.lang.Thread.run(Thread.java:637)
AWT-EventQueue-0 (13):
java.lang.Thread.dumpThreads(Native Method)
java.lang.Thread.getAllStackTraces(Thread.java:1511)
forge.error.ErrorViewer.printError(ErrorViewer.java:140)
forge.error.ErrorViewer.showErrorAllThreads(ErrorViewer.java:98)
forge.error.ErrorViewer$ShowAllThreadsAction.actionPerformed(ErrorViewer.java:210)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
javax.swing.AbstractButton.doClick(AbstractButton.java:389)
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1223)
com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:137)
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1264)
java.awt.Component.processMouseEvent(Component.java:6348)
javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
java.awt.Component.processEvent(Component.java:6113)
java.awt.Container.processEvent(Container.java:2085)
java.awt.Component.dispatchEventImpl(Component.java:4714)
java.awt.Container.dispatchEventImpl(Container.java:2143)
java.awt.Component.dispatchEvent(Component.java:4544)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
java.awt.Container.dispatchEventImpl(Container.java:2129)
java.awt.Window.dispatchEventImpl(Window.java:2475)
java.awt.Component.dispatchEvent(Component.java:4544)
java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
AWT-AppKit (10):
Reference Handler (2):
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
AWT-Shutdown (11):
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
java.lang.Thread.run(Thread.java:637)
DestroyJavaVM (14):
TimerQueue (15):
java.lang.Object.wait(Native Method)
javax.swing.TimerQueue.run(TimerQueue.java:232)
java.lang.Thread.run(Thread.java:637)
Signal Dispatcher (5):
Finalizer (3):
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Memory Leak
by DennisBergkamp » 13 Jan 2010, 17:35
Ah, I haven't actually updated the Deck Editor image displaying yet, it still the old way
How long did it take before you go the error?
The new (in-game) way of displaying cards also breaks the full-size image feature (when hovering over) Vasiliy added.

The new (in-game) way of displaying cards also breaks the full-size image feature (when hovering over) Vasiliy added.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by Chris H. » 13 Jan 2010, 19:05
`DennisBergkamp wrote:Ah, I haven't actually updated the Deck Editor image displaying yet, it still the old wayHow long did it take before you go the error?
The new (in-game) way of displaying cards also breaks the full-size image feature (when hovering over) Vasiliy added.
In the deck editor it takes several dozen or so cards to get the error. I notice a slight delay in displaying the jpg pictures for a few cards and then I get the error.
I just tried playing a game and I noticed the lack of pictures displayed in the picture panel region. Tis a work in progress.

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Memory Leak
by DennisBergkamp » 13 Jan 2010, 19:54
Wait, so the big pictures aren't displaying for you in the bottom right ? (I know the full "zoom" isn't working, but large pictures should still be displayed in picture panel).
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by Chris H. » 14 Jan 2010, 00:23
`DennisBergkamp wrote:Wait, so the big pictures aren't displaying for you in the bottom right ? (I know the full "zoom" isn't working, but large pictures should still be displayed in picture panel).
No, there is no jpg image in the bottom right corner. I get the textual card detail panel in the top right, but no jpg picture. r269 and r270 are both missing this picture panel. I tried with the LQ and the HQ jpg pics.

`
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Memory Leak
by DennisBergkamp » 14 Jan 2010, 01:53
Ah, wow. Weird... did you add google-collect-1.0.jar and jsr305.jar to your build path? I'm assuming you did, because I don't think stuff would even compile without those.
EDIT: I just imported the latest SVN and added it to a new project, then added all libraries in /res/lib. Images show up just fine for me... perhaps it's a Mac specific thing? I'll test this on a Mac at a friend's house. Are you getting any error message when you select a card by the way?
EDIT: I just imported the latest SVN and added it to a new project, then added all libraries in /res/lib. Images show up just fine for me... perhaps it's a Mac specific thing? I'll test this on a Mac at a friend's house. Are you getting any error message when you select a card by the way?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by Chris H. » 14 Jan 2010, 03:21
`DennisBergkamp wrote:Ah, wow. Weird... did you add google-collect-1.0.jar and jsr305.jar to your build path? I'm assuming you did, because I don't think stuff would even compile without those.
EDIT: I just imported the latest SVN and added it to a new project, then added all libraries in /res/lib. Images show up just fine for me... perhaps it's a Mac specific thing? I'll test this on a Mac at a friend's house. Are you getting any error message when you select a card by the way?
I can not explain it.

My .classpath states:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/google-collect-1.0.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/jdom-1.0.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/jl1.0.1.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/jsr305.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/napkinlaf-1.2.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/napkinlaf-swingset-1.2.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/nimrodlf.jar"/>
<classpathentry kind="lib" path="/Users/chrish******/workspace/ForgeSVN/res/lib/substance.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
I just played a game with r270 and was able to finish without any errors.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Memory Leak
by DennisBergkamp » 14 Jan 2010, 04:27
Yeah, that looks good. I'll mess around with it on a mac...
In the worst case, you could fix it for your local version by just reverting it to the previous GuiDisplay3.java.
In the worst case, you could fix it for your local version by just reverting it to the previous GuiDisplay3.java.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Memory Leak
by DennisBergkamp » 14 Jan 2010, 17:38
Is anyone else that has SVN access getting this problem by the way?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
45 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 11 guests