# Allocation Tracking

Goal: To track allocations’s happening during the lifetime of a Ruby process.

Outcomes: When I run a program to completion with allocation tracking enabled I should present enough data to be able ot produce the following artifacts:

• a cumulative and non-cumulative time series of all allocations during the programs lifetime
• a visualisation of the count of allocations of different sizes being made during the programs lifetime
• a visualisation of the size of allocations originating from each call site over the lifetime of the program

What do I need In order to acheive the outcomes, I think that, for each allocation, we need to record:

• the time that the allocation happened
• the size of the allocation in bytes
• from which function did the allocation originate (ie. which function called calloc,malloc, or realloc)

## What are my options?

### MallocStackLoggingNoCompact & malloc history

• macOS only
• UI only provides for attaching to a currently running process. There’s no way of running a consistent reproducible measurement over the lifetime of a process that terminates
• no timestamps

### mtrace

• GNU GCC extension and Linux only
• doesn’t provide timing information, only address, size and caller (stacktrace)

[DTrace]

## manual instrumentation of a ruby binary

• would allow me to customise the output
• fragile, changes upstream could break the patch
• time consuming to implement
• would upstream consider something like this?