[Scilab-Dev] who(): how to count used memory

Samuel Gougeon sgougeon at free.fr
Sun Feb 26 19:10:08 CET 2017


Hi Clément,

Le 22/02/2017 à 09:44, Clément David a écrit :
> .../...
> At runtime in release mode, Scilab 5 `who()` was able to return the size of the allocated data but this is not implemented yet as this is not clear to us if we should return the size of the allocated raw data or the size of the Scilab value. For exemple :
>
> a = zeros(10,10);
>
>   1. `a` is 10x10 matrix of double, and thus with size:  10*10*8 bytes.
>   2. `a` is an ArrayOf<double> with size : sizeof(types::Double) + 10*10*8 bytes
>
> Both computation are valuable, to determine either the data weight in memory or the memory allocated by scilab to use them.

Up to now, the memory used by the container was included in who() results.
Why not allowing both results, and implementing an option to let the 
user choosing the counting mode?

IMHO, returning the data memory without the container could become the 
default. The relative difference between both gets very small as the 
sizes of data increase.
For sparse encodings, the indices locating each non-zero or true value 
could be accounted with the values (so not being considered as part of 
the container), because the memory used to store indices is proportional 
to the number of non-zero values. The container being just the 
"structural" remainder.

By the way, it would be much clearer to return the number of bytes 
instead of the equivalent number of decimal numbers. This unit (8-bytes 
sometimes called a "word" in the help) looks screwy. It is 
straightforward to understand it only for decimal numbers (and only with 
real values), while bytes are datatype independent.
If back-compatibility is of concern, this could be returned with a new 
unit="bytes" option. Otherwise, it could become the default.

HTH
Samuel




More information about the dev mailing list