About garbage collector efficiency using local variables

Yes, these are in UTPlayerController.

Only does a “WorldInfo.ForceGarbageCollection(bool);”, I have tested this function manually, and only does a CG in that time.

But it does not prevent it from doing it every 30 seconds. I think that these lines are to force a GC in some moments, for example when you enter or exit from a menu or pause, to minimize the hitching.

According to the Epic documentation, it is impossible to avoid GC, but you have to try to have the minimum number of objects to check so that the peak is not too high.

Currently I have about 300,000 objects in the map, the peak is about 45 ms. But in a blank map with UTgame there are 115,000 objects and the peak is 16 ms, for only a floor and a cube meshes (was a surprise for me to see the high number of objects in the world).

if you go to content browser and go to the scene tab how many show in that? My biggest map is 2734 items in the scene. Where do you find the total amount of objects in the map? it looks like scene covers everything in my map but the player and weapons and menu stuff.

I think you are talking about actors, not objects (although actors are objects too).

I have 259 actors in the persistent level, and in the city stream level, about 1600 actors. In game, about 1200 NPCs are loaded. So they can be about 3100 actors loaded once.

But it seems that every actor has a lot of objects attached (skelmesh component, voices, LE, etc).

The engine blank map has about 115,000 objetcts, and there are only a floor, a cube, sky, lights, fog… and no much more.

I have searching for this problems and I found some UE3 games with the same issue, and some players talks about changing valours in the ini’s:


But no changes in my case. Perhaps in the cooked game.

I have found this too:
TimeBetweenPurgingPendingKillObjects = 30

I have incremented to 120 and seems to work fine, the hitch is higher (from 50 ms to 62 ms) due more objects to purge, but happens every 2 minutes instead 30 secs. I think is a good deal.

I’m going to increment to 600 to see what happens. I can do a GC manually for example when open the pause or inventory, or the player is idle.

First test:

[0902.62] DevGarbage: Collecting garbage
[0902.67] DevGarbage: 50.814915 ms for realtime GC
[0902.80] DevGarbage: 133.373119 ms for unhashing unreachable objects
[0903.70] DevGarbage: GC purged 261649 objects (591699 → 330050)

objects purged takes 133 ms, instead 3 or 4. The peak is higher, but it’s one time every 10 minutes. The game seems stable, also the RAM.
if there are no unexpected problems, it seems like a good solution.

we have those two set to 0


and this at 60


The two firts parameters don’t affect nothing in my case, same objects to chech, same times, etc. I have to test them with a cooked game.

With time between purging i’m doing tests with a value of 600. Works fine, stable. The times are x3, about 150 ms every check instead 50, but every 10 minutes instead every 30 seconds. Perhaps a value of 300 is more reasonable.

The iteration time is the same, but the purge time is bigger because there are more objects acumulated to delete.

There are some forced GC by the engine, for example when a stream level is loaded.
I was wondering why the engine took so long to load a stream level even if it was very small… I didn’t know that a GC was done before.

So, this is the bad part, more objects to purge when a stream level is loaded.

good to see you figured it out. Always nice to solve an irritating problem.

Thank you, I hope this works well, without surprises.