Landscape Memory Bug (Leak?)

I’ve noticed a problem when moving my project from 4.13.2 to 4.14.1 that there’s a memory bug associated with the landscapes where if I reload any level with a large landscape (not sure which size it starts occurring but going with the biggest size which I currently want has an issue: 255x255, 2x2, 16x16, 8161x8161, 256) or a different level and go back to the same one with the landscape, the memory is never freed and any memory associated with the landscape is added back on top, ranging from 50 to 300 MB every reload. I tried this with both level streaming and open level commands and was able to reproduce this on a new project as well.

Hey ujrkingdom,

I am not getting the same results when testing in a new blank project using an 8x8 landscape. I have attempted to load the level while in PIE as well as in Editor, and both seem to free up the memory and stay consistent.

Can you provide me with steps to reproduce this issue on my end?

Could you also provide some screenshots showing the increase in memory when you reload the level?

Thank you,

Andrew Hurley

Hi Andrew,

Can you try using the largest landscape size possible, after doing a little bit more testing I found that it only reproduces with very large landscapes. After poking around in the source code I found it may potentially be related with the texture and weight maps. I’ll post some screenshots when I get back from work.

Thanks,

Ujwal

Steps to Reproduce:

  1. Create a landscape with these parameters:

    • Section Size: 255x255
    • Sections Per Component: 2x2
    • Number Of Components: 16x16
    • Overall Resolution: 8161x8161
    • Total Components: 256
  2. Go to the level blueprint and setup some logic to Open the level or stream the level on a button press or however you see fit.

  3. Launch the project as a Standalone game or in any instance where the project runs as its own process.

  4. Now keep reloading the level to see the memory increase. At these settings I currently range from 100 to 300 mb increase at every reload.

Here are the screenshots, take note of the memory usage for the first Unreal Engine Process:

http://i.imgur.com/dUrAZJq.jpg

First Reload

http://i.imgur.com/toOzPqx.jpg

Second Reload

http://i.imgur.com/6lIVePZ.jpg

Third Reload

http://i.imgur.com/nZqvoCb.jpg

Fourth Reload

http://i.imgur.com/fMf3Xg0.jpg

30+ Reload

http://i.imgur.com/r1SVlRB.png

Task Manager Memory Usage

Hello ujrkingdom,

So I ran some more tests and actually encountered a blocker when trying to test the memory leak. I will say the tests I ran (reloaded the level 10+ times) were not producing a memory leak on my end. I did experience a crash however, which I have logged a ticket.

The crash I logged could very well be related to the memory leak/issue you are reporting, but it will be hard to tell until it gets fixed and you run additional tests. For tracking purposes you can see the issue I logged by following the link below.

UE-40210

Let me know if you have additional questions or comments.

Thank you,

Andrew Hurley

Hi Andrew,

I was wondering what kind of machine you were testing this on and how you were testing it? I went and tried testing this again on all my windows machines on versions 4.14, 4.15 and 4.16 and on some of my friend’s windows based computers, and they all produced the same result.

I don’t think this is an isolated problem. I’m not sure if this occurs on Mac and Linux.

Thanks,

Ujwal

I tested on my work machine which is pretty powerful, and I was able to reproduce the crash on my end. However, after I tested in the preview release (4.15 preview 4) I did not get the crash to occur.

Myself as well as the engineer who was assigned to fix the issue, were no longer able to reproduce the crash. You can get more details by reading the bug I have linked in my answer above.

If you are still getting this crash, please provide us with steps and your crash logs so I can have this ticket investigated further.

Thanks,

Andrew Hurley

So I wasn’t talking about the crash, but about the memory leak. Are you sure you were testing this correctly? I posted a link to this on the ue4 reddit page to see if anyone else could reproduce the leak, and one person who was running archlinux was able to.

I also did a git bisect to see where the leak originated from, and it pointed to the physx upgrade from 3.3 to 3.4

https://github.com/EpicGames/UnrealEngine/commit/36caee758dd76cc543b5bfbbc8842619ab09848c

If possible can you try testing this again, and if you still can not reproduce it, would it be possible for us to do a skype chat or something so I could talk to you further about this. This leak is a pretty big roadblock on my project as I have two levels with very big landscapes.

Thanks,

Ujwal

So there are known performance issues and crashes with the PhysX 3.4 upgrade which we hope are addressed in the 4.15 release. Since there were so many unique crashes and issues, we have attempted to fix as many as possible, but since we are about to release the official 4.15 binary, would you mind retesting in that version to see if you are getting the same results.

If this continues to be a blocker, I would look at breaking up your two large levels into more manageable landscapes and components so you can control the stream etc. better.

Thanks,

Andrew Hurley

Hi Andrew,

Sorry to bother you about this, but I was able to fix the memory leak and made a pull request on github, if possible could you review it or get someone else to?

https://github.com/EpicGames/UnrealEngine/pull/3276

Thanks,

Ujwal

We have someone assigned to triage your pull request. We appreciate your patience while we review the issue.

Thank you,

Andrew Hurley

Same here, tiled landscapes stay in ram even if i switch to another blank level. I can only build lights or package if I restart editor. Maybe it can’t tell if the blank map is part of the tiling so it does not dump the other sublevels?!