## `prog::memuse` -- memory usage of a computation

#### Introduction

`prog::memuse(`stmt`)` shows the memory usage for computation and loading library functions while evaluating `stmt`.

#### Call(s)

`prog::memuse(stmt)`

#### Parameters

`stmt` | - | a MuPAD statement

#### Returns

the result of `stmt`

#### Related Functions

`Pref::verboseRead`, `prog::trace`, `prog::profile`

#### Details

- `prog::memuse(`stmt`)` shows the memory used while evaluating `stmt`.

- `stmt` is evaluated by `prog::memuse`. If any function or library is loaded, `prog::memuse` prints the increment of memory usage.

  In the end, a summary is printed showing the memory usage in two parts: `loadproc` means the memory used by loaded functions and libraries, `executing` means the memory allocated while computing.

- The result of `prog::memuse` is the result of the evaluation of `stmt`.

- `prog::memuse` works only on Unix-like machines. It uses the temporary file `/tmp/mem.tmp`.

#### Example 1

The example shows the memory usage of a first call of the function `testtype`: The library `Type` and the object `Type::Unknown` are loaded:

    >> reset():
       prog::memuse(testtype(x, Type::Unknown))

          'LIBFILES/Type'                  : 16.4 kB
          'TYPE/Unknown'                   : 1.4 kB

          loadproc                         = 17.9 kB
          executing                        = 0.4 kB
          All                              = 17.5 kB

                                       TRUE

The next example shows the memory usage for creating a large MuPAD object. The result is not shown (suppressed by `:`):

    >> prog::memuse([random()] $ i = 1..1000):

          loadproc                         = 0.0 kB
          executing                        = 112.3 kB
          All                              = 112.3 kB

#### Background

- MuPAD does not load all its library functions on startup or after a `reset()`. This saves a lot of time and memory. The library functions are loaded on their first use, which may in some cases cause a noticeable delay on the first invocation.

#### Changes

- new function

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000