Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check memory allocation line by line in Julia

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?

like image 666
Fazeleh Avatar asked Jan 10 '18 03:01

Fazeleh


1 Answers

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.

  • Memory allocation analysis

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.

like image 188
HarmonicaMuse Avatar answered Nov 03 '22 01:11

HarmonicaMuse