[???] GC can't keep up while the game is paused

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!

[???] GC can't keep up while the game is paused

Postby phantombeta » Mon Nov 02, 2020 7:14 am

No idea when this showed up, but it has probably been around for a long time.
Basically, when the game is paused, GC collection slows down to a crawl. This means that, if a normal menu allocates classes constantly, the GC never collects memory fast enough to offset the constant increase, and you end up with a net increase in RAM usage.

You can reproduce this with Nash's PDA starter kit:
  • Clone the repo or download the source Zip and launch GZDoom while using the entire folder as a file, with Doom 2 as the IWAD.
  • Start the game and do "stat gc" in the console.
  • Pick up the items in front of you, then press the Use Inventory key on the item you get.
  • Click any of the entries in the list.
  • Memory allocations will now be too fast for the GC to keep up with. Once "Alloc" reaches "Thresh", it'll be stuck in the Sweep phase.
If you add "menuactive = OnNoPause;" to the Init function of PDAMenu (In "zscript/PDAMenu.zc"), the issue never pops up. Once Alloc reaches Thresh, it starts collecting dead objects just fine.
Doing "gc pause 1; gc stepmul 400000" in the console also seems to help while the game is paused.

In general, this is a pretty serious issue that needs to be fixed. There's no reason for GZDoom to slow down the GC like this when the game is paused.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: Brazil, South America, Earth, Orion-Cygnus Arm, Milky Way
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [???] GC can't keep up while the game is paused

Postby Player701 » Mon Nov 02, 2020 8:05 am

Also confirmed to happen with RRWM's HUD, which uses a widget system that involves creating a lot of small objects on each draw pass. Guess I never noticed this because I usually minimize the game instead of pausing it, and also maybe because I have 32 GB RAM. :roll:
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [???] GC can't keep up while the game is paused

Postby Gutawer » Wed Nov 18, 2020 6:53 am

Since this effects ZForms so much I've looked into this and the cause is fairly simple - the GC is normally called via CheckGC once per thinker per tick, and while the game is paused, thinkers aren't ticked, so the GC is never called apart from a few scattered calls to CheckGC (which are the cause of this bug not happening if stepmul is set to a very high amount). A simple solution here is just to call GC::FullGC before the early return in line 112 of p_tick.cpp. I'm not sure if there's a better solution but in my testing this doesn't result in any major performance problems (especially since the game gets locked to 35 FPS when the game is paused anyway).
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: [???] GC can't keep up while the game is paused

Postby Gutawer » Tue Nov 24, 2020 7:32 pm

I've PR'd the fix described above here: https://github.com/coelckers/gzdoom/pull/1242
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest