RealDocs

UKismetSystemLibrary::CollectGarbage

function Engine Blueprint Since 4.0
#include "Kismet/KismetSystemLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallable

Description

Requests that the engine delete all unreferenced UObjects, queuing garbage collection to run at the end of the frame.

Caveats & Gotchas

  • Can cause a noticeable hitch — the header itself warns this is a slow operation and should only be triggered where a frame stall is acceptable (e.g. loading screens).
  • This queues collection for end-of-frame rather than running it immediately, so don't expect memory to be freed synchronously when this call returns.
  • Forcing GC too frequently defeats the engine's own GC scheduling heuristics and can hurt performance more than it helps — prefer letting the engine manage collection timing except during known safe windows.

Signature

static void CollectGarbage()

Return Type

void

Example

Force a GC pass during a loading screen C++
// Safe to hitch here since a loading screen is covering the viewport
UKismetSystemLibrary::CollectGarbage();

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.