Memory Insight not detailing Alloc callstacks (ASIS)

Hello!

We currently have a dev branch that is based off the UE 5.5 branch as of about a couple months ago. We are working on going from 4.27 to 5.5 and have been trying to get as close as possible to the runtime memory usage as we have in 4.27. We are about +30-40mb delta in 5.5 from 4.27. Just for context, we use forward shading and are on OpenGLES 3.1, Vulkan disabled, with Android Single Instance Service. I am also capturing from Linux platform. I have another ticket looking to memory saving pointers which is here: [Content removed]

We have ran MemReports and LLM reports and have been able to get some useful information, however we are trying to get more detailed information through the Memory Insights tool, specifically capturing each alloc’s callstack. However for some reason, as noted in my other ticket, I only see the LLM tagged memory and the total memory, however the Alloc Count/Free section and the actual callstack information is not being captured when I look at the Investigation tab for any time range. I am running with Development build config and with the following cmd-line params:

“-tracehost=127.0.0.1 -cpuprofilertrace -statnamedevents -trace=default,memory,metadata,assetmetadata”

I have also made sure to add UE_INSIGHTS_SYMBOLPATH env var which points to the libUnreal.so symbols created after I run our Android build script.

Here is a screenshot of what an example memory insights capture looks like:

[Image Removed]

In the other ticket mentioned above, I also made sure under the Modules tab to load the symbols files (which for Android I believe is libUnreal.so located in <ProjectDir>/Binaries/Android/RvnHmi_Symbols_v1/RvnHmiarm64/libUnreal.so). And it did look like it loaded successfully and that 10032490 symbols were loaded. However, there are still no Allocation Events and I don’t see any .ucache file generated in the Trace store directory (which was supposed to be generated according to the other ticket).

Any ideas of how we can get this information working in Memory Insights?

Thanks!

Nevin

Hi,

If I understand correctly, you are trying to look at the memory alloc/free event callstack on Android but it is not working. You are also running Unreal Insights on Linux (and capturing on this machine). So, either the callstacks are not captured at runtime or the callstack are not resolved. We didn’t test this workflow of running UnrealInsights on a Linux machine, but it’s working on Windows and it should probably work on Linux too, but it is untested. Can you check if you have followed the steps below:

To enable memory tracing:

  • Pass -trace=default,memory -tracefile=files/trace.utrace to the command-line of the game. (Prefer -tracefile over -tracehost as the latter is too slow on Android.)
  • Create the UEEnableMemoryTracingLight.txt file (I think that for UE 5.5, you just need UEEnableMemoryTracingLight.txt, but in 5.4 you needed the other… I put both)
    • adb shell run-as %package_name% touch files/UEEnableMemoryTracing.txt
    • adb shell run-as %package_name% touch files/UEEnableMemoryTracingLight.txt
  • Run the game.
  • Retrieve the *.utrace file from the device.

To disable memory tracing:

  • Remove -trace=… -tracefile=… from the command line of the game.
  • Remove the UEEnableMemoryTracing.txt file (UE 5.5):
    • adb shell run-as %package_name% rm files/UEEnableMemoryTracing.txt
    • adb shell run-as %package_name% rm files/UEEnableMemoryTracingLight.txt

To enable tracing of additional libc.so events (malloc/free/etc):

  • Add -ScudoMemoryTracing to UBT when building your game.

Let me know if I understood correctly the issue and if the solution helps.

Regards,

Patrick

Thanks Patrick for the information. Just had a couple of quick questions:

  • Just to confirm, we currently use the Android Single Instance Service and aren’t running a standalone app on the target so the Unreal service gets invoked from a client app. So is it still fine to do it this way (as in launch the client app which then starts the Unreal Service) or should I run the command to launch the Unreal activity directly? Currently we are able to do that by running this:

`adb shell am start %com.unrealservicepackagename%/com.epicgames.unreal.GameActivity`

  • For this file UEEnableMemoryTracingLight.txt that we create, nothing is supposed to go in it?

Thanks!

Nevin

Hi,

I’m not familiar enough with Android to know if it is fine to run Android Single Instance Service… and the expert is current on vacation… So, just try it, but typically, if the code runs… it runs and it should emits the events if they are enabled… So if you get other event types… you should also get memory events too. As far as I known, the file UEEnableMemoryTracingLight.txtis just there to enable/disable tracing. Here what I found when I searched the code:

D:\UE_5.5\Engine\Build\Android\Java\src\com\epicgames\unreal\GameActivity.java.template

boolean bEnableFullMemoryTracing = new File(GameApplication.getAppContext().getFilesDir() + "/UEEnableMemoryTracing.txt").exists(); boolean bEnableLightlMemoryTracing = new File(GameApplication.getAppContext().getFilesDir() + "/UEEnableMemoryTracingLight.txt").exists();Regards,

Patrick

Hey Patrick,

Thank you for the additional information. So I tried a few things and have no luck yet for capturing alloc events. I did the following:

  1. Added “-trace=default,memory -tracefile=files/trace.utrace” in cmd-line
  2. Created UEEnableMemoryTracingLight.txt and then additionally UEEnableMemoryTracing.txt when just the Light version didn’t work.
  3. Added -ScudoMemoryTracing to our UAT build command
  4. Built with Development configuration
  5. I then ran both via ASIS as well as launching via standalone APK

I see that the utrace file gets generated and I pulled it via adb. However when I open it in insights I am still not seeing alloc events being captured. Here is a screenshot of what this trace looks like and the session info:

[Image Removed][Image Removed]

Any ideas what might be going on here? Anywhere in Engine code I can add some debug print to see why it’s not being tracked?

If I run in Standalone mobile in the editor after adding the “-trace=default,memory” cmd-line, it seems like it works there, but not on target.

Thanks!

Nevin

Hi,

I don’t know what’s going on, but the next thing I’d do is to check if tracing code itself:

D:\UE_5.5\Engine\Source\Runtime\Core\Private\ProfilingDebugging\MemoryTrace.cpp

void MemoryTrace_Alloc(uint64 Address, uint64 Size, uint32 Alignment, HeapId RootHeap, uint32 ExternalCallstackId) { .... }Check the following thing:

  • If the code is compiled -> just put a error in the function above… if the code is enabled, compilation will fail.
  • You can check that the module is linked -> comment the entire function above. The linker should not find the implementation and report the missing symbols
  • Run the application and put a breakpoint in the function above.
    • If the debugger stops on your breakpoint, debug further and check if something is written.
    • If the breakpoint never hits, then just do add a dummy allocation to your code (or find an existing one) and step in code until you reach the allocator and see why MemoryTrace_Alloc would not be called.

Regards,

Patrick

Hey Patrick,

So interestingly, I redid all of the steps from your first reply and it seemed to work this time! I think possibly one thing was where I had to put those two empty txt files. I put them in both of these paths this time and it seemed to work. I didn’t check which one was the right path but looks like it worked this time so I think we are good.

/data/user/10/<UE_Package_Name>/files/UEEnableMemoryTracing.txt

/data/user/10/<UE_Package_Name>/files/UEEnableMemoryTracingLight.txt

/data/media/10/Android/data/<UE_Package_Name>/files/UEEnableMemoryTracing.txt

/data/media/10/Android/data/<UE_Package_Name>/files/UEEnableMemoryTracingLight.txt

Thanks! Now I’ll take a look at analyzing the allocs. If there is any additional documentation on this, please let me know! Otherwise, this ticket can be closed.

Nevin

Hi Nevin,

I’m glad you were able to get it working! There is no other documentation as far as I’m aware other than this: https://dev.epicgames.com/documentation/en\-us/unreal\-engine/memory\-insights\-in\-unreal\-engine.

Regards,

Patrick