Reputation: 1088
I am working on a custom embedded Linux distribution, libc is glibc-2.22.
How to track memory allocations/frees for an application while the application runs in automation for long duration. Are there hooks in glibc that will generate logs each time an allocation/free happens in my application?
Upvotes: 0
Views: 908
Reputation: 33727
There is a glibc branch with a high-performance allocation tracer:
It's still a bit rough, but it has been used with some degree of success with multi-threaded, allocation-intense workloads.
Upvotes: 0
Reputation: 213877
Are there hooks in glibc that will generate logs each time an allocation/free happens in my application?
No. Writing to log on every allocation would be
Your requirements are not unique: e.g. Google runs applications for many days, and developers often want to know how much memory is being consumed by which parts (when you run 100s of 1000s of applications, a wasted MB here and there quickly adds up).
To this end, tcmalloc comes with heap profiler, which can answer many of above questions. So does jemalloc as well.
Upvotes: 0