4.10 Crash when Editor idle too long

Hi !

My editor will crash after idle for a period of time(maybe 10~20min).
The crash report says about out of memory.

Do every one encounter this? Or it is because my project? I am doing a SteamVR project.

MachineId:C3FFA36F4DC1EA595CCE61A0879B4829
EpicAccountId:1bf90486bf0640d5a1120ecfcff643af

Unknown exception - code 00000001 (first/second chance not available)

"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\Core\Private\GenericPlatform\GenericPlatformMemory.cpp] [Line: 91]
Ran out of memory allocating 3

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\misc\outputdevice.cpp:374]
UE4Editor_Core!FGenericPlatformMemory::OnOutOfMemory() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\genericplatform\genericplatformmemory.cpp:92]
UE4Editor_Core!FMallocTBB::Realloc() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\hal\malloctbb.cpp:99]
UE4Editor_Core!FHeapAllocator::ForAnyElementType::ResizeAllocation() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\containers\containerallocationpolicies.h:344]
UE4Editor_Engine!operator new() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\containers\array.h:2671]
UE4Editor_Engine!FGPUSpriteParticleEmitterInstance::AllocateTilesForParticles() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\particles\particlegpusimulation.cpp:3545]
UE4Editor_Engine!FGPUSpriteParticleEmitterInstance::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\particles\particlegpusimulation.cpp:3186]
UE4Editor_Engine!UParticleSystemComponent::ComputeTickComponent_Concurrent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\particles\particlecomponents.cpp:3803]
UE4Editor_Engine!UParticleSystemComponent::TickComponent()

Hello ,

If you’re using Windows, can you try opening the Task Manager and monitoring UE4’s memory usage to see if the editor’s memory usage is rising while you’re not using the editor?

We haven’t heard from you in a while, . Are you still experiencing this issue? If so, please try monitoring your memory usage in the editor so that we can see if a memory leak could be the issue. In the meantime, I’ll be marking this issue as resolved for tracking purposes.

There is a bug here, I’ve fixed it in my local build.

In ParticleGpuSimulation.cpp, there is a FGPUSpriteParticleEmitterInstance::Tick() method which continually adds particles to a NewParticles array. Further on, there is a FFXSystem::SimulateGPUParticles() method which takes those items from the individual emitter NewParticles arrays (via a Simulation object) and appends them into one massive static NewParticles array.

The bug arises when you leave a world ticking without rendering it, ie anytime you’re working on assets with a level loaded in the background. The Tick() keeps accumulating particles but Simulate never runs, so the NewParticles arrays of every emitter get quite large over time (1M+ per emitter). When you do finally switch back to a view which causes those emitters to render, the append operation into the massive static array causes repeated Realloc calls, copying 100M+ particles back and forth across gigabytes of memory. It hangs the editor for a while at best, and crashes with an out-of-memory at worst. Task manager will typically report oscillating memory consumption of the editor during a “hang” of 10-30GB.

My fix: inside Tick(), after adding the NewParticles in the emitter, I cap the size of NewParticles to EmitterInfo.MaxParticleCount:

if (EmitterInfo.MaxParticleCount > 0 
	&& NewParticles.Num() > EmitterInfo.MaxParticleCount)
{
	NewParticles.SetNum(EmitterInfo.MaxParticleCount);
}

Hello AndyCampbell,

As it seems that you were able to fix the problem, would you be able to submit a pull request to our Github repository? If you can provide the fix, it would be reviewed and quicker to get implemented if it’s deemed compatible. If you do still have access to your callstack from when you did get the crash, that would be helpful to include as well.