Fast memory saturation then slow cool down ?

Hello everyone,

When reloading my saves, i get some serious slow down and sometimes “out of memory” crashes.
So i made some tests and came to the following.

When i load them automatically (in a for loop), the memory explodes very fast, but cools down when the loading is over.

My actors are quite heavy on memory so i could understand that, but i can manually add them at will with no problem at all.

I use the same functions for automatic loading and manual spawning so there should be no difference, yet the difference in memory management seems dramatic.

I made a short video to illustrate the problem (sorry you have to go full screen otherwise you won’t be able to read):

In order to investigate and try so solve, i got rid of the loop and made a more elegant mechanic (based on timers) where i can wait some time between each character.

  • when i wait less than ~15 seconds between characters, i quickly saturate the memory
  • when i wait more than ~20 s, then no problem.

So there seems to be some minimal cooling time to wait but i can’t afford to wait 20 s between each object spawn when reloading a save.
But if i don’t wait long enough the memory adds up and goes crazy (sort of like a convolution in time with a fast boost / slow cool down).

I don’t think i do anything fancy in my code, here the core code i use to reload. I create an empty shell, then load the properties from an FArchive, then apply them (CompleteObjectRefresh() function):

// spawn
AYagCharacter* SpawnedCharacter = GetWorld()->SpawnActor<AYagCharacter>(BP_YagCharacter, FVector(0.f), FRotator(0.f), SpawnParams);
if (!SpawnedCharacter) return;

// add in actor array

// load properties
SpawnedCharacter->SaveLoadCharacter(FromBinary, this);

// apply properties

The YagCharacter class is quite heavy on memory, but again i can add them manually with no problem and in anywase, 20 of them shouldn’t be any stress at all for UE4 on a correct computer (core i7 + 16 go ram + geforce 750 here).
I do not feel strong enough on the subject to open a bug report but i really don’t understand what’s going on.

Any ideas ?

Thanks !!