3

I'm working on a project about the resolution of sparse linear systems (using the UMFPACK library and testing all the FEMLAB matrices) and I have to check how much RAM this resolution require (for each matrix).

I have to test the UMFPACK in different programming languages, so I already wrote some code in MATLAB where I found the following commands:

[user, sys] = memory, in particular the user.MemUsedMATLAB.

Now I have to write the same software using Julia programming language, but it seems difficult to find some similar commands; I'm very new to Julia and I just tried the command @time, but I'm not able to store the number of allocated bytes of memory in a variable. This is very important, because in the end I need to plot a graphic with the values of allocated bytes of memory for each matrix.

Does anyone know a solution to my problem? How can I get the RAM used by my code in a variable? Is there an equivalent command to MemUsedMATLAB in Julia?

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
  • 1
    Perhaps a good start would be Julia's documentation for [memory allocation analysis](https://docs.julialang.org/en/stable/manual/profile/#memory-allocation-analysis). – rickhg12hs Jun 02 '17 at 12:14
  • also, for consistency in comparing different programs, you might want to rely on system facilities instead (e.g. find a way to parse the output from one of the methods mentioned [here](https://stackoverflow.com/questions/131303/how-to-measure-actual-memory-usage-of-an-application-or-process)) – Tasos Papastylianou Jun 02 '17 at 19:47

1 Answers1

1

The @time macro displays how much memory is allocated (in total) when you call the code in question. This includes temporaries — something that Matlab won't tell you. You can access the values with the @timed macro; see it's help for a description of each return value:

julia> @timed rand(100000)'*rand(100000)
(25069.751546076346, 0.002270112, 1600336, 0.0, Base.GC_Diff(1600336, 2, 0, 7, 0, 0, 0, 0, 0))

help?> @timed
  @timed

  A macro to execute an expression, and return the value of the expression,
  elapsed time, total bytes allocated, garbage collection time, and an object
  with various memory allocation counters.

But that's not the memory at rest. It's the total amount of memory that was allocated during the computation of the expression. This can be vastly higher than your system's available memory if there are lots of temporaries.

You can also use the Base.summarysize function to get an estimate of individual object sizes, but the computation there is approximate.

mbauman
  • 30,958
  • 4
  • 88
  • 123