GC and allocated memory

Hello.

In 4.12.3 I created simple project that is creating 1000 actors with destructible component and then destroy all the same actors, and run GC at last. memory usage in Windows task manager is 155,832KB and right after crating 1000 actors is: 660,324KB and after removing all of 1000 actors is: 505,496KB, Running GC leads to: 341,748KB and it does not go below than this. Here’s setting of my project.

I run this project with launch on Windows. and found memory info from task manager. (UE4Game.exe)

Why does GC cannot collect all the 200MB memory?

Hi,

It’s difficult to say without looking at it but the first thing that comes to mind is that it could be a combination of the allocator not freeing memory back to os (keeping it for future allocations) and some global structures growing and not releasing memory after removing the actors (we often reset the count of the array without freeing the memory to reduce memory churn across frames). I’d also dump the list of UObject to see if all of them really went away with GC (obj list).

Hello Robert!

Obj list class=NewBlueprint_C displays 0 after running GC, but memory is not freed.

In other posts related to GC also says it is from not freeing allocated memory. I’m attaching sample project. You can check it out by running binary after packaging project to win64 platform. Not freeing memory even if a long time passes seems not normal.

link text

Like I said, it could be due to multiple factors. Another thing would be to use ‘mem’ console command that will show you how much memory the allocator is using (look for ‘Allocator Stats for …’ in the log. This could be down to the fact that the memory inside of the allocator becomes fragmented with other allocations and it can’t free all the pages to the OS.