Does TripleA have memory leak?

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Does TripleA have memory leak?

Pulicat
Does TripleA experience a memory leak?

I often experience "java heap memory space" insufficient errors when playing large maps like RSOC or Civil War. Incidentally, this never happens when Civil War is loaded locally, only when it is loaded on an internet game.

I looked up the "java heap" memory error and found that it could have one of two causes:

1) The program has a memory leak, does not discard objects normally but instead accumulates a pile of trash which becomes a drag on the memory.

2) The program really does consume that much memory and an insufficient amount of memory is allocated to it.

So the question is, do we have a memory leak issue, and how do we fix it? And if it really does need that much memory to play large maps, is there a way to allocate a significantly larger chunk of memory to TripleA? Is this governed by something in the code itself?

Pulicat
how now brown cow?
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Bung
I know for example, if you examine the launchers for linux (.sh) file, you can adjust the amount of memory that triplea is launched in the command  "java -Xmx256m"

I do find that my game is likely to crash after a few uses of the battle calculator. And I have had one or two other unknown errors during crashes that I've posted to the bug tracker.

I think that it is honestly going to be really hard to figure it out, and I know the few active maintainers we have need a well-deserved break after this latest stable.

I urge anyone that knows some any compsci students with nothing to do, to get them to have a look maybe.
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

ComradeKev
Administrator
Bung wrote
...and I know the few active maintainers we have need a well-deserved break after this latest stable.


I have access to some profilers that I'll run the engine through.  I'm sure we have at least a couple of processes that are in deed leaking.... but they're not used often.  I'll try to incorporate any changes into the next unstable.
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Pulicat
So i've ruled out that its a memory allocation problem.
I ran TripleA from terminal with 2gb of RAM: java -Xmx2000m -jar triplea.jar

...and I get the same problem upon startup of the map. Basically the map tiles fail to load and the map is blank. I can still scroll around, I can still open up the side tabs and history tabs, its just that the map is a sea of light gray.

And, this problem only occurs when I am in a network game with somebody else hosting. It doesn't happen in a local game against AI.


So the question is, is this something wrong with running TripleA in general or just something wrong with my computer? Initially i thought it might have been a memory leak but after testing it like this it no longer seems to be so.


For reference, this is the error:

Exception in thread "Map panel background drawer" 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:324)
        at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:537)
        at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:521)
        at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:171)
        at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
        at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
        at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
        at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
        at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
        at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
        at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3261)
        at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3246)
        at games.strategy.triplea.image.TileImageFactory.loadUnblendedImage(TileImageFactory.java:445)
        at games.strategy.triplea.image.TileImageFactory.loadImage(TileImageFactory.java:322)
        at games.strategy.triplea.image.TileImageFactory.getImage(TileImageFactory.java:260)
        at games.strategy.triplea.image.TileImageFactory.getBaseTile(TileImageFactory.java:214)
        at games.strategy.triplea.ui.screen.BaseMapDrawable.getImage(IDrawable.java:449)
        at games.strategy.triplea.ui.screen.MapTileDrawable.draw(IDrawable.java:353)
        at games.strategy.triplea.ui.screen.Tile.draw(Tile.java:165)
        at games.strategy.triplea.ui.screen.Tile.getImage(Tile.java:103)
        at games.strategy.triplea.ui.BackgroundDrawer.run(MapPanel.java:1225)
        at java.lang.Thread.run(Thread.java:637)
java.lang.OutOfMemoryError: Java heap space
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
        at java.lang.Class.getMethod0(Class.java:2670)
        at java.lang.Class.getMethod(Class.java:1603)
        at games.strategy.engine.data.GameParser.setValues(GameParser.java:1170)
        at games.strategy.engine.data.GameParser.parseAttachments(GameParser.java:1101)
        at games.strategy.engine.data.GameParser.parse(GameParser.java:125)
        at games.strategy.engine.framework.ui.NewGameChooserEntry.<init>(NewGameChooserEntry.java:27)
        at games.strategy.engine.framework.ui.NewGameChooserModel.createEntry(NewGameChooserModel.java:163)
        at games.strategy.engine.framework.ui.NewGameChooserModel.populateFromDirectory(NewGameChooserModel.java:180)
        at games.strategy.engine.framework.ui.NewGameChooserModel.populate(NewGameChooserModel.java:82)
        at games.strategy.engine.framework.ui.NewGameChooserModel.<init>(NewGameChooserModel.java:35)
        at games.strategy.engine.framework.startup.mc.GameSelectorModel.loadDefaultGame(GameSelectorModel.java:217)
        at games.strategy.engine.framework.startup.ui.MainFrame.clientLeftGame(MainFrame.java:120)
        at games.strategy.triplea.ui.TripleAFrame.leaveGame(TripleAFrame.java:549)
        at games.strategy.triplea.ui.TripleAFrame$5.windowClosing(TripleAFrame.java:569)
        at java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:332)
        at java.awt.Window.processWindowEvent(Window.java:1862)
        at javax.swing.JFrame.processWindowEvent(JFrame.java:274)
        at java.awt.Window.processEvent(Window.java:1820)
        at java.awt.Component.dispatchEventImpl(Component.java:4714)
        at java.awt.Container.dispatchEventImpl(Container.java:2143)
        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)


EDIT: FYI I am running Java 6 Update 17 for Mac OS X 10.6.2
how now brown cow?
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

ComradeKev
Administrator
Pulicat wrote
And, this problem only occurs when I am in a network game with somebody else hosting.
What does the host computer have for memory?
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Pulicat
Well, I don't know. The two times I tried were with lalapalooza and Boshido hosting, and neither hoster had the same problem (map loaded fine for them), but me the guest had the problem.

Pulicat
how now brown cow?
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

ComradeKev
Administrator
See if you can recreate it as will as the host.  I'd be interested to know.
If emailing me at ComradeKev at yahoo.com , please add TripleA to the subject line
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Pulicat
Unfortunately at my current location, I can't host for quite a while. Spent all day yesterday trying to port forward my router -- ostensibly it is port forwarded yet it keeps saying my laptop is not reachable from the internet.
how now brown cow?
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Sean Bridges
Administrator
Maps can take a lot of memory.   Memory used will be affected by the monitor size, and the map size.  Do you have a really large monitor?

The game does leak memory in the sense that it never forgets old moves (always available via history).  
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Pulicat
I have a 17 inch screen at 1440x900 resolution and i almost always play with full screen.

Maybe thats why?
how now brown cow?
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Sean Bridges
Administrator
17 inch monitor should be fine.  I have a 24 inch monitor and it works without problems.  It's probably either a very large map, or a very long game.

You can see where memory is being used by using visual vm.  Look at the memory profiling section of,

http://java.sun.com/javase/6/docs/technotes/guides/visualvm/profiler.html
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Bung
In reply to this post by ComradeKev
I've noticed since Ubuntu forced me to openjdk, my battle calculator has been slowing my game down to a crawl after a few uses during a multi (more then it used to [which it did]).

I'm going to see about switching back to Sun's java and seeing how it goes.
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

erik542
In reply to this post by Sean Bridges
Sean, I have had the exact same problem as puli has been describing. I'm on OS X 10.4.11 with a 13 inch screen. I get the upon opening RSOC which definitely means it isn't because of a long game. RSOC is 9MB, NWO is 7MB, TRS is 11 MB. I have run NWO and TRS games up to 15 rounds without error, so it certainly isn't the map size that's the problem. It seems to be much more mysterious.
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Veqryn
Administrator
In reply to this post by Pulicat
I just wish to do some comparisons, so that maybe we can figure out what or why Civil_War is causing my computer, and puli's, to crash (only crashes when attempting to host).

I have a 10 year old laptop.
it is only a 1.4gz old single core
with 500mb of ram
and an old nvidia 440go video card with only 64mb or ram on it (i think?)
and I'm running windows xp sp3, with antivirus, firewall, sql host, sql writer, office suite, oracle, and a whole ton of other crap that i need to get rid of (basically, i'm saying i have a high start up memory usage of about 320mb in pagefile)
oh, and my screen resolution is 1600x1200 with max 32bit colors (am i crazy? why do new laptops have a smaller resolution than me? why do hdtv's have a smaller resolution than a 10 year old laptop? suckers!)


YET
i can host every map in the world except pulicat's map

I can run and host Domination, Galaxy, NWO, and other crazy big maps

here are some comparisons between pulicat's map, and Domination

Domination:
units.scale=0.75
map.width=7556
map.height=3646
basetiles are 560kb
relieftiles are 11000kb
size of XML is 540kb
number of units on the map at startup: huge number!


Civil War by pulicat
units.scale=0.75
map.width=3900
map.height=3500
basetiles are 550kb
there are no relief tiles
size of XML is 520kb
number of units ont he map at startup: small number



SO.....

by all comparisons, Domination is bigger and harder on my computer in every way.  It is almost twice as big.

so why is Civil_War giving me an out of heap-memory error when i try to host games?
(but i can host domination fine)
(i tried hosting a game, with just myself, noone else allowed in, and I crashed.  but i can play locally just fine)


I'll keep looking at the xml and polygons file and stuff... who knows

sgb, kev.... i posted it on the downloads list if you want to easily download it and have a look too

thx,
veqryn



edit:

possibilities:

1) it could be that maps that have lots of single placement (single entry in placement.txt) use up a lot of memory.... perhaps TripleA has a very inefficient way of putting the next unit with a black line next to the last placement?

2) railroads?

3) really big decoration files?

4) high territory density?  (of course, other maps have more territories, like diplomacy has many more on screen at once because of the dummies and i do notice a slowdown because of it, but not that much)

5) large polygon file?  the poly file is 2mb, which slightly smaller than domination, but domination is also twice as big a map... i dunno

6) Pulicat, destroyer of threads, eater of memory?

7) NOs or other v3/aa50 rules aspects/properties are hard on the computer?


possible debugging to do pulicat:

a) make sure the place.txt has at least 3 entries/coordinates for each territory

b) temporarily remove decorations

c) try commenting out certain parts of code and seeing if it clears things up.  like for example, commenting out all railroads.
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Wisconsin
In reply to this post by Sean Bridges
I've been playing NWO and I've found out (Using Task Manager) that TripleA was using over 1.2 GB of memory by round 45! Is this a normal amount for a map that size?

Thanks,
    Wisconsin
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Wisconsin
In reply to this post by Veqryn
I got this error when trying to start the Civil War map posted on the Depot:

java.lang.IllegalStateException: Could not load misc/unitchart.png
        at games.strategy.triplea.ui.MapData.loadImage(MapData.java:688)
        at games.strategy.triplea.ui.MapData.loadDecorations(MapData.java:200)
        at games.strategy.triplea.ui.MapData.<init>(MapData.java:155)
        at games.strategy.triplea.ui.UIContext.internalSetMapDir(UIContext.java:194)
        at games.strategy.triplea.ui.UIContext.setDefaltMapDir(UIContext.java:162)
        at games.strategy.triplea.ui.TripleAFrame.<init>(TripleAFrame.java:196)
        at games.strategy.triplea.TripleA$1.run(TripleA.java:150)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(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)

Does this just happen for me, or does it happen for everyone?

By the way, I restarted before starting so that shouldn't be causing it.

Thanks,
    Wisconsin
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

aaaaaa2011
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Veqryn
Administrator
In reply to this post by Wisconsin
yes, but I can actually play NWO to the 45th round, and host it too,

i can't do that, not even to start it, 1 round, by my self, hosting in the lobby, with civil war


(also, i told pulicat how to fix the unitchart.png thing, and he will do that soon [he has wrong case])
Please contribute to the TripleA 2013 donation drive:
http://tripleadev.1671093.n2.nabble.com/2013-TripleA-Donation-Drive-tp7583455.html
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

erik542
In reply to this post by Veqryn
"b) temporarily remove decorations"

this fixes rsoc.
Reply | Threaded
Open this post in threaded view
|

Re: Does TripleA have memory leak?

Galactus Cactus
In reply to this post by Pulicat
Can confirm Bung's find: Use of Battlecalc slows games down up to a freeze, within 1-2 rounds. Specifically on a fast (i5) machine, Windows7, NWO (host and guest), and the worse the further the game progesses.
Others report too that trouble seems to affect Windows7 specifically. Java memory usage increased by that time significantly (~200MB to ~250MB a round further), but not enough to explain the crawl at all (6GB machine).

All pretty unspecific info, I know, but best I can provide. Maybe it helps.

When I devour this planet, I'd like a TripleA without this as a topping, tastier.

Galactus
12