Memory leak in MaterialEditor

Hello,

I’ve noticed the following memory leak when using the DLSS plugin. I would be getting crashes on editor shutdown after opening a material editor, the plugin checks if any DLSS features are still in use.

Some DLSS features are still being held via the ITemporalUpscaler::IHistory object in the material editor viewport’s FSceneViewState

The reason the FSceneViewState sticks around is that there is a circular reference between SMaterialEditor3DPreviewViewport and SMaterialEditorViewportToolBar.

SMaterialEditor3DPreviewViewport holds onto SMaterialEditorViewportToolBar as it’s a child widget of the viewport.

SMaterialEditorViewportToolBar holds onto the viewport via the MaterialEditorViewportPtr SharedPtr.

Turning MaterialEditorViewportPtr into a TWeakPtr seems to fix the issue. I’ve not noticed any problems when doing this.

Regards,

Benjamin

Steps to Reproduce

  1. Put a breakpoint in the SMaterialEditor3DPreviewViewport destructor function.
  2. Open a Material asset
  3. Close the asset editor window
  4. Notice that the breakpoint does not get hit

Sorry, nevermind. We checked the code in 5.6 and this was already fixed.

Hello [mention removed]​,

Thanks for the update. Glad to hear this has been resolved. I’ll go ahead and close the case.

Best regards,

Francisco