Issue
In windows, I've used Heap32ListFirst / Heap32ListNext to iterate over the heaps list, and then for each heap I'd use Heap32First / Heap32Next to get every block.
Is there an equivalent way of doing so in Linux, glibc or otherwise? I couldn't find any functions to walk the heap.
Solution
You can use sbrk(0)
to get the "program break" pointer, which is effectively the "end" of the heap. Walking it, however, requires knowing implementation details of your particular malloc()
. So no, there is not really a standard way of doing what you're asking.
See also: How to iterate all malloc chunks (glibc)
Answered By - John Zwinck