Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Force Garbage Collection


So I've got a game in which a lot of actors are spawned, at a rapid rate. They also get destroyed almost as fast. Since the latest Rocket upgrade, I seem to get a massive slowdown after about a minute, until a garbage collection happens. We're talking of an fps drop from 120 fps to ~20fps, then straight back up to 120. Looking at the object count at the top of the screen, we're talking going from ~300k to ~450k until the gc comes into effect.

I can force a garbage collection by using the console command, 'OBJ GC', but I can't find a way to automate that through script. When I execute a console command, using OBJ GC, I just get a crash.

Is there any way to modify to GC rate? Preferably through just script.

Cheers, Chris

Product Version: Not Selected
more ▼

asked Mar 11 '14 at 05:22 AM in Everything Else

avatar image

ue4-archive ♦♦ STAFF
50k 3670 1999 9124

avatar image DanHollingsworth Feb 20 '19 at 08:47 PM

You should never ever allocate and destroy anything rapidly "At a rapid rate" - If you are doing this then you should be using a spare list. And reusing those allocations.

Also you cannot simply force a garbage collection any time you want. There are specific points in the update loop where it is possible.


This occurs after all the tick groups have run. so NO you cant run it on a timer. You tell it to ignore its heuristic, and force a GC at the end of the current frame.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Dear Chris,

The title of your thread, in World.h :)

Running When You Want

You could run it on a timer :)

 //void ForceGarbageCollection( bool bFullPurge = false ); //I use True

Crashes Solution -> IsVallidLowLevel()

For actors that could be garage collected,

you can do this check

 if(!Actor->IsValidLowLevel()) return; //dont try to access null or is-being-destroyed

I find that catches a lot of what would otherwise be crashes when GC has just been forced


more ▼

answered Mar 11 '14 at 05:22 AM

avatar image

ue4-archive ♦♦ STAFF
50k 3670 1999 9124

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question