Memory Profiler 2 immediately crashes itself on start

I’m trying to get the memory profiler to work for our project, by enabling it in the Target.cs file:

bUseMallocProfiler = true;

Compiling with it enabled works fine but the resulting program immediately crashes.

It seems to break during static initialization of some random unrelated string. Did anyone ever get it working?

Wait, I thought you were running the packaged executable with memory profiling enabled. You should leave bUseMallocProfiler set to false (and rebuild the engine, etc.) to use the editor. Set bUseMallocProfiler to true when compiling the package executable for your game (are you using ‘Development’ and ‘Win64’?). Once you have your game executable built, turn bUseMallocProfiler back off, fully rebuild the engine, then package your game (with the executable using the memory profiler). When you run the packaged executable, it should create the .mprof file.

Wait, I thought you were running the packaged executable with memory profiling enabled. You should leave bUseMallocProfiler set to false (and rebuild the engine, etc.) to use the editor. Set bUseMallocProfiler to true when compiling the package executable for your game (are you using ‘Development’ and ‘Win64’?). Once you have your game executable built, turn bUseMallocProfiler back off, fully rebuild the engine, then package your game (with the executable using the memory profiler). When you run the packaged executable, it should create the .mprof file.

Maybe you should just run the game uncooked with the memory profiler enabled?

Are you rebuilding the entire engine? Try changing the ‘bUseMallocProfiler’ in TargetRules.cs from ‘false’ to ‘true’ and then rebuild the entire engine.

Yes, setting bUseMallocProfiler in my Target.cs has the same result in a source build. That part is definitely fine - it’s compiling in the malloc profiler. Otherwise it wouldn’t get to crashing either.

Did you ever manage to use it yourself?

Yes, I use the malloc profiler frequently. Setting ‘bUseMallocProfiler’ true in your module’s Target.cs files does not enable this engine-wide. This needs to be turned on in TargetRules.cs and the entire engine (and your project) needs to be fully rebuilt.

I’ll try that now. I’m trying to use it on a packaged build though (development config), are you sure the Target.cs does not apply to the everything then? There is only one per target, it’s not specific to modules.

Yes. Your module’s Target.cs doesn’t apply to everything else. The UnrealBuildTool’s TargetRules.cs does apply to everything built by UBT (including the enigne, any modules, and game projects).

Hm, still not working. The editor manages to start, but it crashes again when starting PIE or attempting to cook, so I can’t actually test whether this changed anything for the packaged build.

Also wtf that is one deep call stack.

Building a packaged exe and launching it in the binaries folder still dies immediately instead of printing the usual “you need cooked content” message, so that didn’t change anything here :frowning:

I’ve tried this but the result is still just it crashing on start. :frowning:

For the packaged executable that would make sense. For an uncooked build, it would make a difference for the rest of the engine.

By the way, modifying TargetRules.cs or my packaged target.cs file results in the exact same binary except for the compiled in compile time. So that method is definitely working.

Ah. Well at the moment neither is working. The packaged build which I tried originally (and still am trying) just crashes immediately.

This is working again in 4.20 Preview 3.

No, 4.19.2 crashes on start when trying to use it. I still don’t know why.

It’s not urgent though so I will just do this after 4.20 is released.

Did you get it working in 4.19 though?