Memory Allocation keeps increasing from persistent loading and unloading of levels

I’m not sure what section to put this under as I am not sure if this is a bug with the engine or something wrong with my code, but I’m facing a pretty crucial problem where every time I switch levels the amount of memory being used by the process increases, usually by 200 to 300 MB. I am using world composition and manual level streaming right now am doing all my loading and unloading in my Base level blueprint.

I’ve included two memreport files where I tried to see the difference between successive level switching.

Here’s my main level blueprint.

I also get warnings like this in the log:

LogPlayLevel: GumDrops: [2016.12.15-00.25.22:555][877]LogStreaming:Warning: Package /Game/Levels/WorldMap1Ouput/WorldMap1Ouput_x2_y3 has been removed multiple timesLogStreaming:Warning: Package /Game/Levels/WorldMap1Ouput/WorldMap1Ouput_x2_y3 has already been removed but is still being loaded.

LogPlayLevel: GumDrops:
LogPlayLevel: GumDrops: [2016.12.15-00.25.22:690][895]LogStreaming:Warning: Package /Game/Levels/WorldMap1Ouput/WorldMap1Ouput_x2_y3 has already been removed but is still being loaded.LogStreaming:Warning: Package /Game/Levels/WorldMap1Ouput/WorldMap1Ouput_x2_y3 has already been removed

LogPlayLevel: GumDrops:
LogPlayLevel: GumDrops: [2016.12.15-00.25.22:718][896]LogStreaming:Warning: Package /Game/Levels/WorldMap1Ouput/WorldMap1Ouput_x2_y3 has already been removedLogStreaming:Warning: Package /Game/Levels/WorldMap has been removed multiple times

LogPlayLevel: GumDrops:
LogPlayLevel: GumDrops: [2016.12.15-00.25.23:736][998]LogStreaming:Warning: Package /Game/Levels/WorldMap has been removed multiple timesLogStreaming:Warning: Package /Game/Levels/WorldMap has already been removed but is still being loaded.

LogPlayLevel: GumDrops:
LogPlayLevel: GumDrops: [2016.12.15-00.25.24:238][ 12]LogStreaming:Warning: Package /Game/Levels/WorldMap has already been removed but is still being loaded.LogStreaming:Warning: Package /Game/Levels/WorldMap has already been removed

LogPlayLevel: GumDrops:
LogPlayLevel: GumDrops: [2016.12.15-00.25.24:247][ 13]LogStreaming:Warning: Package /Game/Levels/WorldMap has already been removedLogStreaming:Warning: Package /Game/Cinematics/shots/shot0010/HappyValleyIntroSequence_shot0010_001 has been removed multiple times

Bumped into a similar issue. Have you figured that out by any chance?

Hey bstone,
I set up another question that was suggesting this as a memory leak, and the staff developer who responded wasn’t able to reproduce it exactly on his end but he did get a crash when trying to build the light map. Although I’m using dynamic lighting for my world so I’m still sure that it has to do something with either the weight, height or texture maps. You can check the post out here:

Hey ujrkingdom, thanks for pointing me to that other issue. I’m not sure if I face a memory leak. I was worried more about those warnings with assets being removed multiple times or removed while still being loaded as those most likely lead to a network related check getting triggered which I was trying to fix/work around.

Oh, the issue pretty much dissappeared after I reset up the level streaming, turns out there was an issue in how the blueprint commands were being called repeatedly with my setup.

Huh, that’s great to know as it gives some hope but the funny thing is that I’m witnessing those warnings in the Shooter Game’s Highrise map. And it doesn’t do anything fancy with streaming levels besides just having them set to ‘Always Loaded’. So hopefully I won’t see that once I plug my original maps in. Thanks.

I’m currently investigating a similar problem on our end. We have an Actor that must be placed in the level that caches materials for later usage.

Unreal 4.19

I created a empty level with a cube, light, camera and the formentioned actor, and copied the level.
Starting into one of the levels directly from the editor via Play-Button, it works as intended. Even in the same unreal session I can go into either of them without problems, as long as I do it via the Play-Button.

Launching into one of the levels via the Play-Button and using the console command “open LEVELNAME” to open the other level, memory starts to go crazy. While loading the first level via Play-Button, memory shows ~3GB in editor. After opening the second level via the console command, memory shows ~14GB (before caching the materials in the second level!) and loading took realy long!.

The cache is just an TArray with object pointers:

    UPROPERTY(BlueprintReadOnly, Category = "Cache")
    TArray<UMaterialInstance*> MaterialCache;

The issue seems to be a general memory leak issue that does exist in 4.19 when opening another level.

This specific issue has been rectified as of 4.16, it was a problem with the physx asset not being deleted when a landscape was destroyed on level unload.