Gpu memory leak in CubemapHelpers::GenerateLongLatUnwrap?

The RenderTargetLongLat object of type UTextureRenderTarget2D created inside CubemapHelpers::GenerateLongLatUnwrap appears to be leaked. Running this function frame after frame causes a GPU memory crash with texture allocation. Calling ConditionalBeginDestroy() on the render target has fixed the problem, though I am not sure what is the most appropriate deallocation method here. https://github.com/EpicGames/UnrealEngine/blob/master/Engine/Source/Editor/UnrealEd/Private/CubemapUnwrapUtils.cpp#L88

It looks like this issue would still be present on the master branch, despite the transition to the NewObject<> allocation method.

Hi num3ric,

I just wanted to let you know that we have started looking into this issue. Do you have any additional information that will help us to reproduce the memory leak?

Hey num3ric,

Ah, the render target needs its resource explicitly freed (rather than waiting for GC to occur).
try adding:

// Clean up.
RenderTargetLongLat->ReleaseResource();
RenderTargetLongLat->RemoveFromRoot();
...

I’ll add this to main branch too. Thanks!