In case you want to try testing for random memory related crashes with malloc stomp

Creating this small topic for anybody who wants to use the malloc stomp feature for UE5 (because there seems to be no online information left about it that can be accessed…)

Its a pretty easy basic way to find exact timings when memory gets overridden by other things and it helped me find one seemingly random crash, but I could not find any online information about how to make it work which could still be publicly accessed, and some information is outdated…

So, if you are trying to find out how to enable this in UE5:

  1. Go to \Engine\Source\Runtime\Core\Public\HAL\MallocStomp.h and add this line at the top:

#define WITH_MALLOC_STOMP 1

(this apparently was updated some time ago, most posts mention to add USE_MALLOC_STOMP but thats incorrect at the time of writing)

  1. Run the game with the -stompmalloc argument.

E.g:

UE5_GameExecutable.exe -stompmalloc

After doing the above, it should now crash whenever the memory gets improperly overridden (i think). You can then connect to the instance with a debugger (e.g Visual Studio) and find out where the bug actually is.

Note that it will only kick in if BOTH of the above are active. That means that you cannot test this in play-in-editor mode, and need to either build an executable or run Standalone (and make use of the Launch arguments in the Editor Preferences).

2 Likes