GPU memory leak when using scenecapture2d capture on every frame with editable transform widget movement

I have a character blueprint with a scenecapture2d component set up under a camera component to get a first person view kind of effect. The camera is set to copy transforms from a transform type variable set to editable and show 3d widget is enabled. I noticed I was getting crashes when moving this widget in the world.

It seems like the scenecapture2d when set to capture every frame in combination with moving the transform widget allocates a lot of GPU memory. Nothing happens when the scenecapture2d is set to not capture on every frame. Also after the memory leakage if you compile the blueprint the memory usage is reset to normal levels. But if you don’t compile the blueprint (or something similar) the memory stays allocated and can create a crash if you continue for example moving the widget. If the memory was reset upon stopping the movement of the widget I probably wouldn’t have had any crashes and not notice this at all but it seems the memory stays in use even after moving it.

A basic repro case:

  1. Create a new blank project with starter content.

  2. Add a BP to the chair mesh.

  3. Create a render target texture.

  4. Add a scenecapture2d component to the BP and set it to use the render target texture. Confirm that it is set up to capture every frame.

  5. Create a variable and set it to the transform type, compile and set it to editable and enable 3d widget.

  6. Save the project.

  7. Disable position grid snapping and scrub the transform widget in the world forwards and backwards while monitoring GPU memory somehow (I use GPU Tweak II but something like GPU-Z should work too).

  8. Crash. (or stop before crashing)

  9. Repeat the same process but with capture on every frame disabled - should work fine.

Hey cyaoeu,

So I gathered your information and know that what you are experiencing is a known and expected issue. As long as you are adding a SceneCapture2D component and creating the render target within the blueprint itself (not the content browser), and then calling that blueprint to update every frame is expected to have memory consumption issues.

This is because when you call it to update every frame, it is literally creating a new render target every tick, which can quickly fill up your memory (especially the larger the render target resolutions). Blueprints only garbage collect ever so often without compiles, so all of your render targets are not being collected. Our developers also keep this in mind as there is a difference between the render target created in the content browser and how it behaves versus one created via the construction script.

Thank you,

I am not creating the render target texture in blueprints though. In fact I have no blueprint code related to render targets in my test above. Just selecting the render target texture created in the content browser in the component (scene capture) is enough to cause memory issues when moving a widget like my example.

I mean if it’s working as intended I don’t have anything to say really but it seems a bit extreme that that checkbox alone should change the memory usage from basically nothing to 300-500MB/s with a 256x256 render target.

Would you mind sharing with me a test project to make sure we are running identical tests? I have your steps, but I want be certain that the issue you are reporting is indeed a bug, because I do not want to rule out that possibility.


Sure! Test project
I removed the variable because just moving the object is enough. I just don’t understand why CaptureEveryFrame is having a negative impact in the editor. Is there any workflow using a scenecapture2d and capturing every frame in the editor? For me capturing every frame is only important in the game itself so I would like to avoid the issues when moving such a component in the editor. For now I can work around it by either toggling off CaptureEveryFrame when moving things/widgets in the editor and then turning it back on again, or compiling blueprints randomly to garbage collect. It’s a bit awkward though and if I forget to I might crash.

There are a number of ways to enable/disable capturing of not only single frames, but enabling ‘CaptureEveryFrame’ only when you need it. This can be done as easily as exposing that variable to your blueprint, and calling it to enable/disable.

Assuming you are getting a Crash Report Window, would you mind providing me with your crash logs so I can use that information to gather more about the crash itself?

I am going to try and reproduce your issue as it is expected there are some memory concerns when creating the Render Target within the Construction Script, but this shouldn’t occur when created within the Content Browser.

Thanks, for now I set the component to not capture in the component itself and set it to start capturing on begin play and it works fine.

I’m not getting the crash report window, I never have when running out of either RAM or VRAM. What I get is something like this:

Hey ,

Thanks for the clear and precise repro steps. I was able to confirm what you are reporting and have gone ahead and entered a bug report for the issue. You can track the report following the link below on our public issues tracker.


Once the issue has been addressed by our engineers the ticket will be updated and reflected in the public tracker. Let me know if you have further questions or need additional assistance.


Thanks! I can’t view internal JIRA links though. Here’s the issue tracker version! Unreal Engine Issues and Bug Tracker (UE-43455)

Apologies! I’ve updated my link as well to point to the correct location.