What's in the .mem files?


#1

Hello,

I have run julia with --track-allocation=all, and it has generated a bunch of .mem files for my code. Some of my lines are annotated with numbers on the left hand side. What exactly do those numbers mean? Are they somehow related to the output of @time macro (which also reports allocations)?

Specifically, I am puzzled with the following. Apparently, I have allocated 3200 of something by just adding two floating point numbers, and 1600 more by storing a max of two other numbers. Both of these occur in a loop.

3200                     d0 = prev_d[j - 1] + score
1600                     d = max(d0, d)

Some of my lines where I am pretty certain that I am allocating memory don’t have numbers on the left hand side. Should this be reported as a bug?

-     ret = AlignmentContext{AT}(n, m) # this allocates an n x m array

I run Julia 1.0.3 on Linux.

Should I be using a more reliable method of tracking memory allocation?


#2

It’s supposed to be the number of bytes allocated on that line, but unfortunately it’s not super accurate, and often misses allocations. I wrote a bit about it in this post.

As for memory allocated where you think there shouldn’t be: You can verify with @time that memory is indeed allocated there (just put @time in front of those lines).

Unexpected allocations are often caused by type instability. Run @code_warntype for your function and look for any instabilities (i.e. “::Any” colored in red).