Memory leak in 5.2

Hi, the memory is increasing until use all the memory in some hours of use in projects on 5.2 in the editor.
I tried to recompile all the shaders, also tried to switch to forward shading but it didn’t help, the memory keeps growing.

4 Likes

I am having the same issues with just a default 3rd / 1st player templates, changed or unchanged. from 2.5 gig to over 14gig after around 10 minutes of playing, but doing nothing in the default 3rd person template.

Note: This happens upon playing and stopping the play in the editor. Not actively logging anything to my knowledge or purposely lol.

Windows 11 home ed. 22H2
UE Version: Release 5.2.0 - 25360045

  • Verified Engine and Project files.

  • Created New Projects in older engines. “No mem increase “leak””.

2 Likes

BUMP

I’m experiencing the same issue after migrating from 5.1 to 5.2.

I’ve also tried to create a new project in 5.2 (template with example content only), same constant increase of memory usage in editor, also while not playing and without opening new tabs.

When a new PIE session starts nothing is freed up.

I’m building the engine from source.

Tested compiling with VS2022 and Rider2022 on Win10 latest update, NVidia drivers up to date.

The very first run of a new project seems to be less affected by the issue, anyway since the second run the issue becomes easy to reproduce.

1 Like

I have also experienced this for a while and spent hours trying to find the memory leak before coming to the conclusion it was just Unreal. For me, its about 7MB/s.

The only thing I noticed is that it does not happen in levels that only contain Widgets, for example, a main menu.

Debugging using Unreal’s memory tools doesn’t give any meaningful info other than its Untracked Memory.

1 Like

I have the same issue, roughly 5mb/s increase within my project which started with the first person template.

I tried a fresh project with the first person template and again, without any of my modifications the memory leak keeps happening.

Windows 10 Pro
UE Version: Release 5.2.0 - 25360045

I’m having the same problem that’s only started since the move to 5.2; if it helps narrow it down, I’m using forward shading and not using Nanite, Lumen, PCG tools, Strata, or really anything that’s new IN 5.2 in the project. It’s just some functionality present in previous versions of the engine that was updated or changed that caused this.

5.2.1 did not fix it.

[UE5.2, Bug report] Editor crash when PC is idle for a while. Out of memory.

This is a project with a few splines, actors and images in it :') no settings altered

The memory leak I previously mentioned does not appear to be present in Shipping builds so that’s a good thing. But it is annoying when testing builds with non-shipping builds or just staying in the editor.

1 Like

Hey,

we also encountered a memory leak that seems to be caused by viewport rendering, also in packaged games (but we didn’t test shipping builds). Can you please add the following line to your DefaultEngine.ini file and see if it’s still leaking (preferably under RendererSettings)?

r.gpucrash.collectionenable=0

It seems to be important to add this line to the ini and not enter it at runtime.

I guess this is not a fix, but it can help narrow the issue down and maybe help epic fix the issue properly.

sirjofri

9 Likes

What you can also test is, in the editor, close all 3d viewports that are there. Our issue seems to be D3D12 rendering related (GPUProfiler, to be precise), and it’s probably leaking less memory when fewer things are being rendered. It seems the claimed memory is not freed then, but no more memory is leaking.

I also have a bug report (and all necessary data) for our issue prepared and tried to send it in, but the web page was stuck somehow and I don’t want to produce a duplicate.

1 Like

This seems to work for me. Ram stays around 2 gb and doesn’t increase every few seconds. For now I’ll keep it disabled and will wait for a fix.

2 Likes

This workaround works for me, good enough until a proper fix, thanks for sharing your solution.

1 Like

I was going to migrate to 5.2 from 5.1 and now I don’t want to, but thanks a lot for helping community, you are a hero!

I’m having the same memory leak but where is this file? Is it supposed to be in my project or in UE Installation folder?

it should be in <ProjectDir>/Config/DefaultEngine.ini, but if you never changed your project settings and only have some very default project, that file might not exist. You can just create it, but make sure that .ini is the file extension (Windows by default hides the file extensions).

If you have to create the file, you can just paste this text:

[/Script/Engine.RendererSettings]
r.gpucrash.collectionenable=0
3 Likes

Thank you. It did exist and I did write the command but somehow it didn’t work for me.
It’s the same
UE still stalls at small things like saving a variable, deleting a node or even compiling something (no matter the size of the blueprint). This didn’t used to happen in 5.0.3.
The number of Objs randomly increase or decrease. Same with memory. Currently it is at 14gigs but 10 mins ago it was shooting again to 22gigs, even after writing the command you mentioned.

How to fix this? It’s really irritating.

It totally depends on if you run into the same issue. I guess there’s lots of potential for other bugs that lead to memory leaks, so there’s no guarantee that the CVar helps in your case.

For that CVar to actually work, it is important that you start the project with that CVar. Yes, you can set it at runtime, but the issue is only gone when you start the engine with that CVar. Setting it in the DefaultEngine.ini file is the correct way to do that.

Regarding UObjects increasing and decreasing, that should be another issue. That GPU collection feature is not bound to UObjects, but to a data structure like an array, as far as I can see in the code. Note that it’s quite normal for Unreal to seemingly randomly allocate memory for UObjects that pile up until the garbage collector decides to remove them and free memory. Depending on the project a change between 14GB and 22GB can be quite normal, especially if Unreal is doing something in the background, like preparing data for the DDC or loading stuff.

But the strange thing is, this was not happening in 5.0.3

But then what is causing this much Stall ? The stall counter is already on 25 in the past 45 mins. This is not normal to me. 5.0.3 was not stalling this much, nor allocating this much RAM. Something feels off. Is there another way to check what is causing this Stall or memory spike (if memory spike is causing the issue in the first place).
I have no issues with relatively higher memory usage in the editor IF it doesn’t translate to the final build being a memory hog AND If it doesn’t cause any stall.
It’s the random stalls that affect me more right now. I thought it’s because of the memory leak.

Edit - It started happening randomly. A few days back, it wasn’t this serious of an issue. But I haven’t changed any Engine Settings to coincide with this issue.

You can only use profiling tools (or debugging) to find out about it. I don’t think it’s related to the rendering bug discussed in this thread, but of course it’s still annoying and relevant.

What I can tell you, I regularly hit random ensures when disconnecting nodes, mostly by dragging the node and dropping the wire to disconnect it (I know alt-click works, but muscle memory, plus alt key is on my right keyboard half). Hitting ensures sometimes leads to a small lag.

Sorry I can’t help you more, and good luck finding the issue :slight_smile:

1 Like

What is ensure? is it a button that I’m missing? or is it another name for the compile button?
And it’s fine lol. If it suits your muscle memory then it’s the best way.

I have 2 options. Either churn through this or maybe try 5.3. I’m not sure of updating Metahumans to 5.3 (as upgrading to 5.2 from 5.0 took me 2 days to redownload and setup again). Are you aware of this? Will the 5.2 Metahumans in my project simply work with 5.3 or will I be req to download them again?