google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.81k stars 350 forks source link

How to capture memory leaks that consume excessive memory and occur over extended periods of time on the Android platform? #692

Closed jiahengcen closed 8 months ago

jiahengcen commented 8 months ago

Our device has 32GB of memory and a 1TB hard drive. It is an Android device. Our developed app has a native memory leak, with a daily leak of around 1GB. Currently, we are only allowed to configure a 500MB cache space for memory leak capture, and we can only capture memory information for about 3 minutes. Is there a way to provide a larger space and longer monitoring for memory leaks?

LalitMaganti commented 8 months ago

for memory leak capture,

When you say this, how are you capturing the debugging information for the memory leak? Is it using Perfetto? If so, can you please provide the trace, or at least the config used to generate the trace?

As it stands right now this quesiton is very difficult to help with as there is just not enough information present.

jiahengcen commented 8 months ago

An Android 12 device with root access. this is config used to generate the trace capturing.zip python3 ./record_android_trace -c config_memory.pbtx -o native_memory.perfetto-trace

LalitMaganti commented 8 months ago

Is there a reason why you are setting heap_sampling_intervals? Generally, you set sampling_interval_bytes instead. Also have you considered using/tweaking the config printed by tools/heap_profile --print-cofnig instead of manually writing a config from scratch yourself? That script should help create a config which is much more inline with recommendations.