# UCaptureManagerEditorSettings - dangling lambda 

**URL:** <https://forums.unrealengine.com/t/ucapturemanagereditorsettings-dangling-lambda/2670923>\
**Category:** Platform & Builds\
**Tags:** unreal-engine, Epic-Pro-Support, question\
**Created:** [September 30, 2025, 5:28pm UTC](https://forums.unrealengine.com/t/ucapturemanagereditorsettings-dangling-lambda/2670923 "2025-09-30T17:28:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [September 30, 2025, 5:28pm UTC](https://forums.unrealengine.com/t/ucapturemanagereditorsettings-dangling-lambda/2670923/1 "2025-09-30T17:28:50Z")

</div>

Hi Epic. This isn’t an actual question - more of an FYI. Thanks to Stomp2Malloc, I noticed that UCaptureManagerEditorSettings never removes its OnModularFeatureUnregistered lambda. When the editor exits, the dangling ‘this’ pointer captured by the lambda is being accessed, after UCaptureManagerEditorSettings has been destroyed.

It’s an easy fix. I added this method:

```auto
void UCaptureManagerEditorSettings::Destroy()
{
	IModularFeatures::Get().OnModularFeatureUnregistered().Remove(OnModularFeatureUnregisteredHandle);
}

```

​

Combined with:

**OnModularFeatureUnregisteredHandle** = IModularFeatures::Get().OnModularFeatureUnregistered().AddLambda(…

and…

```auto
void FCaptureManagerEditorSettingsModule::EnginePreExit()
{
	UCaptureManagerEditorSettings* Settings = GetMutableDefault<UCaptureManagerEditorSettings>();
	check(Settings);
	Settings->Destroy();
	...

```

That’s it 🙂. It would be good if you adopted this fix, so everyone will benefit, but also future merges of UE will be less painful on our side.

Thanks.

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [September 30, 2025, 5:28pm UTC](https://forums.unrealengine.com/t/ucapturemanagereditorsettings-dangling-lambda/2670923/2 "2025-09-30T17:28:54Z")

</div>

**Steps to Reproduce**  
Load the editor with:

```auto
-stomp2malloc -MallocStomp2MaxSize=9999999

```

(See [Content removed] first!)

Then close the editor. Stomp2Malloc will report the issue.

---

<div class="post-metadata">

**Author:** ![DefaultDeveloper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DefaultDeveloper](https://forums.unrealengine.com/u/DefaultDeveloper)\
**Post date:** [October 3, 2025, 4:55pm UTC](https://forums.unrealengine.com/t/ucapturemanagereditorsettings-dangling-lambda/2670923/3 "2025-10-03T16:55:42Z")

</div>

Hey Kostas, I submitted a speculative fix (I could not get an editor with Stomp2Malloc to boot in my stream). The fix which landed in 46527263 (UE5 Main), it will also be in the 5.7 release.
