`@allocated` vs `@allocations`

Since 1.9, Julia has @allocations, which is

A macro to evaluate an expression, discard the resulting value, and instead return the total number of allocations during evaluation of the expression.

In contrast, @allocated is

A macro to evaluate an expression, discarding the resulting value, instead returning the total number of bytes allocated during evaluation of the expression.

Is there a difference? When should we use which?

One returns a count, the other a “volume” in bytes.

To profile anything but very small functions, I usually use the memory profiler instead. This tells you were and how much memory is allocated by your program.

1 Like

Thanks, my eyes missed that one word of difference.