[erlang-bugs] erts_debug:flat_size/1 wrong?

Michael Truog mjtruog@REDACTED
Fri Sep 26 04:19:55 CEST 2014


Hi,

I have been attempting to compare the output of erts_debug:flat_size/1 
to the memory info at 
http://www.erlang.org/doc/efficiency_guide/advanced.html#id68923 and the 
results show that each term's size is off-by-one (at least for pids 
local/remote, refs local/remote, floats, integers, bignums, binaries and 
atoms).  I know the function is experimental, but this is a bug, right?  
The problem affects top-level terms and nested terms, so it is likely to 
understate the memory with large terms.  I wanted to make sure the 
memory info (in the efficiency guide) was accurate (it seems like it 
is).  I was testing with R16B03 on 64bits.

For example:
1> erts_debug:flat_size(576460752303423488).
2
2> erts_debug:flat_size(576460752303423487).
0
3> erts_debug:flat_size(undefined).
0
4> erts_debug:flat_size([]).
0
5> erts_debug:flat_size([undefined]).
2
% 1 word for each element in the list * 2 elements including []
6> erts_debug:flat_size(erlang:make_ref()).
3
7> erts_debug:flat_size(erlang:self()).
0
8> erts_debug:flat_size(1.0).
2

Thanks,
Michael



More information about the erlang-bugs mailing list