I want to check memory allocation in each line of my code. I used @time
, and I got
5.381438 seconds (2.19 M allocations: 809.021 MiB, 1.08% gc time)
what does (2.19 M allocations: 809.021 MiB, 1.08% gc time)
mean?
My code for some Input is out of memory and I know there is a problem with memory allocation, How can I check memory allocation line by line?
The total amount of allocation can be measured with
@time
and@allocated
, and specific lines triggering allocation can often be inferred from profiling via the cost of garbage collection that these lines incur.However, sometimes it is more efficient to directly measure the amount of memory allocated by each line of code.
To measure allocation line-by-line, start Julia with the
--track-allocation=<setting>
command-line option.When you quit Julia, the cumulative results are written to text files with
.mem
appended after the file name, residing in the same directory as the source file.Each line lists the total number of bytes allocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With