1

Suppose you're working on a C++ program which allocates multiple large buffers at different points in time. Suppose also this allocation doesn't necessary happen by kernel sbrk-like calls, but also internally, i.e. maybe there's some pre-allocation of slabs and allocations within that slab.

Now, you would like to get a timeline, in which different bars/lines correspond to different buffers that you allocate - with the start and end of their life (allocation and de-allocation) marked.

The format could be either raster, or even something as simple as a CSV table with, say, filename,line,size,start "time",end "time"

I put "time" in quotes because although it would be nice to get actual wall-clock time, any well-ordered value might work.

  • Would be nice if this would reasonably support multi-threaded work, but even if it doesn't, that's fine too.
  • The way I phrased the requirement, this will definitely require some modification in the code, so probably this will need to be either a library-only solution or a library + executable tool

Requirements:

  • Gratis
  • Supports Linux
3
  • jemalloc's Heap Profiling might be of interest. There is also a heap profiler called Massif in valgrind.
    – paleonix
    Mar 2 at 15:09
  • @paleonix: Like I said - the allocation doesn't necessarily involve change to the heap size, nor calls to new/malloc... so I don't think those two trackers would be useful for my purposes.
    – einpoklum
    Mar 2 at 15:15
  • If you need to instrument the code either way, using some logger library should be straightforward. Even getting a nice graphical representation seem relatively easy to me, the most complex thing would be to connect allocations to deallocations by matching the logged address, right?
    – paleonix
    Mar 2 at 23:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.