Forge's Garbage Collection
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Forge's Garbage Collection
by VileTouch » 24 Apr 2016, 21:13
As you most certainly know, having forge open for more than a few matches (such as a gauntlet) uses increasing amounts of memory until it ultimately crashes. some would say it's a memory leak, but i disagree. testing different JVM arguments i've found the Garbage First (G1GC) works better than the default setting. (not perfectly, though but...better)
also increasing the heap size to at least 2Gb will delay the inevitable crash. specially when using higher resolution images (200dpi here)
but i would like to know if there is anything else we can do from the user side to at least minimize this problem until a definitive bugfix is implemented.
also increasing the heap size to at least 2Gb will delay the inevitable crash. specially when using higher resolution images (200dpi here)
but i would like to know if there is anything else we can do from the user side to at least minimize this problem until a definitive bugfix is implemented.
"He traded sand for skins, skins for gold, gold for life. In the end, he traded life for sand." - Afari, Tales
Re: Forge's Garbage Collection
by AlexFolland » 17 May 2016, 10:33
This is interesting to me. I can't complete even one game with my sliver combo deck because when I get the Psionic Sliver out, I usually have ~20 slivers on the battlefield and then the game gets super slow for no apparent reason and goes from using 5% CPU to 90% CPU, so if I want to finish the game, it takes half an hour, since one action takes about a minute. I end up just closing the game.
Can you give an example command line for running Forge in such a way that the broken situation is delayed? I want to be able to play my sliver combo deck.
Can you give an example command line for running Forge in such a way that the broken situation is delayed? I want to be able to play my sliver combo deck.
- AlexFolland
- Posts: 41
- Joined: 28 Aug 2012, 15:38
- Has thanked: 4 times
- Been thanked: 3 times
Re: Forge's Garbage Collection
by Fizanko » 18 May 2016, 23:44
I had noticed the game considerably degrading when playing those kind of multiple-token generating decks.
But for what is leading into Forge eating too much ressources and crashing in only a few games i think it may be a (relatively) recent problem.
I mean i remember +/- a year or so ago having sessions in which i played a dozen of games in quest mode without noticing any slowness on what was a weaker computer than i have now. Only problems i could get were the usual bugs (concurrent modification or null pointer or in some version the flickering attack/defense numbers when they were modified).
I have been playing much less games in the last year, so i couldn't really notice when it started, but can anyone that had played much more regularly point to what was the first release that did that ?
Could be helpful for the devs to find what happened that lead into this ressource eating problem.
But for what is leading into Forge eating too much ressources and crashing in only a few games i think it may be a (relatively) recent problem.
I mean i remember +/- a year or so ago having sessions in which i played a dozen of games in quest mode without noticing any slowness on what was a weaker computer than i have now. Only problems i could get were the usual bugs (concurrent modification or null pointer or in some version the flickering attack/defense numbers when they were modified).
I have been playing much less games in the last year, so i couldn't really notice when it started, but can anyone that had played much more regularly point to what was the first release that did that ?
Could be helpful for the devs to find what happened that lead into this ressource eating problem.
probably outdated by now so you should avoid : Innistrad world for Forge (updated 17/11/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Re: Forge's Garbage Collection
by timmermac » 19 May 2016, 00:30
IIRC, Forge doesn't properly remove images and other items from caches, so memory usage builds to the point where it overloads the allocated heap space and crashes the program. This is especially troublsome for the Android version, where available memory is far more limited. With the desktop version and computers with far more RAM becoming commonplace, it might be time to set the default xms amount to 4 gigs along with adding more garbage collection routines to the code. For Android, just adding garbage collection will have to do for now. (Note to self: SELF! Get phone/tablet with at least 2 gigs RAM ASAP.)
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Forge's Garbage Collection
by Fizanko » 19 May 2016, 09:34
Is this a problem specific to Forge, or is it a java global one ?timmermac wrote:IIRC, Forge doesn't properly remove images and other items from caches, so memory usage builds to the point where it overloads the allocated heap space and crashes the program.
Anyways if it's that bad, i guess reducing image size could be very helpfull to deal with the ever increasing memory eating.
Irfanview can batch resize image by the way for those that wants to do that. That may explain why i had been able to play more games in the past, as i always rescale all my Forge pictures to lower size.
A related question :
In order to not have Forge loading so much things in memory and ultimately killing itself, can you remove some sets you never use from the edition folder to prevent all the sets cards and related pictures to be loaded in memory ?
Or do you need to remove more to get rid of such sets ?
probably outdated by now so you should avoid : Innistrad world for Forge (updated 17/11/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Re: Forge's Garbage Collection
by Hanmac » 19 May 2016, 12:25
Hm I need to see how it's currently implemented, but I think the Best way would be to make a Pool pro game where the resources are loaded into. (With that when a game is closed all resources are freed again)
Maybe with a bit ref counter so the same image can be used for multiple games when they are open the same time.
Hm maybe with adding File Watcher so when a file is changed, that cached File is removed from the Pool again.
Maybe with a bit ref counter so the same image can be used for multiple games when they are open the same time.
Hm maybe with adding File Watcher so when a file is changed, that cached File is removed from the Pool again.
Re: Forge's Garbage Collection
by timmermac » 19 May 2016, 17:29
I'm not familiar enough with coding to know for sure, but I suspect that a large part of the issue is that there isn't enough garbage collection being done. If I'm wrong, feel free to correct me. Also, I think desktop Forge could certainly stand to have the maximum memory allocation increased to at least 2 gigabytes, preferably 4. It would be nice if Java, by default, would automatically allocate the majority of system RAM for its use.
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Forge's Garbage Collection
by VileTouch » 23 May 2016, 22:32
but there's a problem with that. if you increase the heap size too much, then the GC has that much more work to do every cycle. thus hurting performance as well.timmermac wrote:Also, I think desktop Forge could certainly stand to have the maximum memory allocation increased to at least 2 gigabytes, preferably 4.
also on x86 systems (or x86 java, even if your os is x64)the vm cannot allocate more than 2gb no matter what. in fact i've found that anything over 1200mb murders performance on 32bits regardless.
"He traded sand for skins, skins for gold, gold for life. In the end, he traded life for sand." - Afari, Tales
Re: Forge's Garbage Collection
by VileTouch » 23 May 2016, 22:44
try this:AlexFolland wrote:This is interesting to me. I can't complete even one game with my sliver combo deck because when I get the Psionic Sliver out, I usually have ~20 slivers on the battlefield and then the game gets super slow for no apparent reason and goes from using 5% CPU to 90% CPU, so if I want to finish the game, it takes half an hour, since one action takes about a minute. I end up just closing the game.
Can you give an example command line for running Forge in such a way that the broken situation is delayed? I want to be able to play my sliver combo deck.
- Code: Select all
java.exe -Xms1024m -Xmx2048m -XX:+UseG1GC -jar "forge-gui-desktop- {insert your version here} -jar-with-dependencies.jar"
( edit: or set both Xms and Xmx to 2048m and see how it goes. in theory it would reduce cpu usage a bit since the vm won't have to worry about resizing the heap to fit each cycle but i haven't tested that in forge so it could go either way)
but i wouldn't use Xmx4g even if you have 8gb or more of ram...seems like too much.
95% of my cards are 480x680px. if yours are smaller, you might have even better performance than i do.
"He traded sand for skins, skins for gold, gold for life. In the end, he traded life for sand." - Afari, Tales
Re: Forge's Garbage Collection
by Fizanko » 29 May 2016, 13:22
That could explain why i could play longer without reaching the wall, my cards pictures are all from the card HQ torrent by default but then i batch rescaled them all with irfanview to 450 pixels in height as it fits perfectly well on my monitor (tall enough so i don't have to force my eyes to see, and small enough to look like real cards on the game preview)
What size are the pictures that are downloaded by Forge for people using the ingame downloader ?
What size are the pictures that are downloaded by Forge for people using the ingame downloader ?
probably outdated by now so you should avoid : Innistrad world for Forge (updated 17/11/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Duel Decks for Forge - Forge custom decks (updated 25/10/2014)
Re: Forge's Garbage Collection
by timmermac » 29 May 2016, 19:15
210x300
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Forge's Garbage Collection
by AlexFolland » 30 May 2016, 09:10
Thanks a lot! I have 16GB of RAM, so "Xmx4g" is surely fine. I overcompensate on RAM since there are many improperly-written programs out there when it comes to memory management.VileTouch wrote:try this:AlexFolland wrote:This is interesting to me. I can't complete even one game with my sliver combo deck because when I get the Psionic Sliver out, I usually have ~20 slivers on the battlefield and then the game gets super slow for no apparent reason and goes from using 5% CPU to 90% CPU, so if I want to finish the game, it takes half an hour, since one action takes about a minute. I end up just closing the game.
Can you give an example command line for running Forge in such a way that the broken situation is delayed? I want to be able to play my sliver combo deck.these are modest settings but you still need a 64bit java. if you have 6gb or more of ram, try increasing Xmx to 3072m
- Code: Select all
java.exe -Xms1024m -Xmx2048m -XX:+UseG1GC -jar "forge-gui-desktop- {insert your version here} -jar-with-dependencies.jar"
( edit: or set both Xms and Xmx to 2048m and see how it goes. in theory it would reduce cpu usage a bit since the vm won't have to worry about resizing the heap to fit each cycle but i haven't tested that in forge so it could go either way)
but i wouldn't use Xmx4g even if you have 8gb or more of ram...seems like too much.
95% of my cards are 480x680px. if yours are smaller, you might have even better performance than i do.
Edit: Thanks to you, I've been able to play this ridiculous modern Sun Droplet tanking deck which has way too many triggers per upkeep!
- AlexFolland
- Posts: 41
- Joined: 28 Aug 2012, 15:38
- Has thanked: 4 times
- Been thanked: 3 times
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: Donaldmourl and 39 guests