Topic: 64KB of GC allocs every frame causes stuttering and freezes

The profiler shows gc allocs of 64.3KB every frame which sums up to around 400MB per round. This can cause stuttering and freezes as reported on other topics. They are not predictable and so some can see the results after 15 mins others immediatly after just some seconds, depending on console, phone, etc.

Are they known and just for logging/debugging stuff? Then I'll have nothing to do smile Or are this the general reasons listed below, then this will take pretty long to hunt/find them sad

In general gc allocs are caused by:
- using LINQ for list-operations
- string values (every time when a string gets changed, for example showing time, internally a complete new string gets created and the old one causes the garbage collector to do his job)
- creating and destroying objects every time when needed (particles, but also other things)
- creating new lists because methodX delivers arrays and methodY needs lists
- some physics stuff like raycasting without using the gc allocs free version which unity provides now

Share

Thumbs up +1 Thumbs down

2 (edited by acidfmhq 2021-03-24 20:07:09)

Re: 64KB of GC allocs every frame causes stuttering and freezes

So first of all the netcode is in fact always running in the background even offline. First place to reduce allocations at least for offline is go to the FluxCapacitor script and find the first time SaveGameState is and then make it so it only runs online or if you have emulateNetwork enabled or the recordToggle enabled.

The second place that causes allocations is within FluxExtensions within the GetInputEvents method so pressing a lot of buttons will cause a lot of GC.Allocs. We had a previous coder try to fix this but it broke the netcode so we had to revert it. Very sure the main issue here is it keeps creating a new Dictionary. But using a reference for this instead of making a new one breaks the input system.

Hopefully what I have here helps you out cause to be honest with you I don't believe this will be fixed anytime soon.

Terrordrome Reign of the Legends Out now on Steam!!
https://store.steampowered.com/app/1291 … e_Legends/
Terrordrome Project Manager

Re: 64KB of GC allocs every frame causes stuttering and freezes

Thank you acidfmhq for providing some further insights.

Especially the part with the Dictionary and referencing. This reminds me of another project I had to tackle all the GC allocs. And this sounds like it will be a lot of work :-(

So this is a part we should expect a bigger portion of help from the developer, but on the other side maybe we should help him to get this done too.

@acidfmhq terrordrome looks great and you can see that a lot of customization and work went into that game

Share

Thumbs up Thumbs down

Re: 64KB of GC allocs every frame causes stuttering and freezes

Thanks for the info acidfmhg.
I haven't had the time to look into that yet, but I'll definitely add this as one my priorities before releasing the next update.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.
Don't forget to check our discord channel.

Re: 64KB of GC allocs every frame causes stuttering and freezes

thanks acidfmhq, this might help with the micro stutters in my game on the psvita.

Share

Thumbs up +1 Thumbs down

6 (edited by acidfmhq 2021-03-27 04:41:06)

Re: 64KB of GC allocs every frame causes stuttering and freezes

Cause you have to think not everyone is going to be making their games only for PC. In order to maximize revenue we all need to get our games on a console. So in the end consoles tend to have limited resources in this case, if UFE continues to collect garbage data in the background it will slow our games down and ruin the experience of our customers.

Having smooth gameplay will keep the player engaged in our games and not getting turned off of it due to seeing jarring movements.

It's bad in Terrordrome but so far no users have reported this issue of seeing stuttering unless they don't have the keen eyes like I do.

Hopefully we will see this fixed sooner or later I'll be happy to see my game looking smooth like most of the latest Fighters out there.

Terrordrome Reign of the Legends Out now on Steam!!
https://store.steampowered.com/app/1291 … e_Legends/
Terrordrome Project Manager

Re: 64KB of GC allocs every frame causes stuttering and freezes

This could also be the cause of certain desyncs users report in our game. Cause if the game has to Garbage collect at a bad time it could cause the netcode to miss a chance to rollback.

Hate to say it but this could also be the reason why other UFE games on steam don't even use the rollback netcode included and use true ggpo. For for the simple fact of all the allocations this netcode can cause.

Terrordrome Reign of the Legends Out now on Steam!!
https://store.steampowered.com/app/1291 … e_Legends/
Terrordrome Project Manager