<div dir="ltr">Hello,<br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 12:28 PM, ash <span dir="ltr"><<a href="mailto:ashley.hewson@oliverwyman.com" target="_blank">ashley.hewson@oliverwyman.com</a><wbr>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I've been getting high values for `erlang:memory(binary)` so I've been looking at the following:<br>
(1) `[erlang:process_info(Pid, binary) || Pid <- processes()]`<br></blockquote><div><br></div><div>This describes the number of off-heap binaries created by the application belonging to the specified process.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(2) `instrument:memory_data/0`<br></blockquote><div><br></div><div>This describes the amount of memory used by the allocator type <font face="monospace, monospace">binary</font>.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(3) `erlang:system_info({allocator<wbr>, binary_alloc})`<br></blockquote><div><br></div><div>This describes the amount of memory allocated into the binary allocator aka <font face="monospace, monospace">binary_alloc</font>. </div><div><br></div><div>None of these will have the same value.</div><div><br></div><div>The binary allocator contains all off-heap binaries and other binary like things (for drivers, nifs and erts things), so it will always be the largest one. </div><div><br></div><div>The binary allocator type is what is used to allocate a off-heap binary. However all off-heap binaries do not have to below to processes, they could also belong to ports, nifs or some other VM internal entity. This value should be smaller then binary_alloc. The pid that you see here is which process CREATED the binary, the ownership of it may later have been shared with a port, nif, or other process, or something else.</div><div><br></div><div>Lastly process_info describes the binaries currently referenced from the heap of the given process. This should be smaller then binary_alloc and the binary allocator type.</div><div><br></div><div>Lukas</div></div></div></div>