process_info(Pid, memory).
does not track off heap binary memory. You can use erlang:process_info(Pid, binary)
or erlang:process_info(Pid, garbage_collection_info)
to get that information.
See the inline comments in this example for details:
2> erlang:process_info(self(), memory).
{memory,142848} %% Original memory
3> <<0:(1024*1024)>>. %% Create a 131072 byte binary
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
4> erlang:process_info(self(), memory).
{memory,142848} %% memory stays the same
5> erlang:process_info(self(), [binary]).
[{binary,[{105025994150080,10,1},
{105025994149712,78,1},
{136391456522688,131072,2}, %% This is our binary
{105025994152344,68,1}]}]
6> erlang:process_info(self(), [garbage_collection_info]).
[{garbage_collection_info,[{old_heap_block_size,10958},
{heap_block_size,6772},
{mbuf_size,0},
{recent_size,137},
{stack_size,26},
{old_heap_size,3126},
{heap_size,6743},
%% It is also part of the below, but in words not bytes, so 131072 / 8 = 16384.0
{bin_vheap_size,16409},
{bin_vheap_block_size,98315},
{bin_old_vheap_size,72},
{bin_old_vheap_block_size,46422}]}]