<div dir="ltr">Hello,<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 19, 2018 at 7:42 AM Devon Estes <<a href="mailto:devon.c.estes@gmail.com">devon.c.estes@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey everyone,<div><br></div><div>First off, I would like to apologize for the following code example in Elixir - it's the language I know best, and where we're having the problem.</div><div><br></div><div>Anyway, I'm one of the maintainers of an Elixir benchmarking tool called Benchee. A few months ago we added memory measurement as a feature in our benchmarking tool. However, with the release of OTP 21, we're seeing some measurements that seem very strange. For example, according to our measurements, the following function uses 0 bytes of memory: `Enum.to_list(1..10)`. On OTP 20, this always uses between 350-380 byes depending on the platform. There are a few other instances of these kinds of functions which we believe should be using memory somewhere, but the results that we get back from our measurements say they are not using any memory, and all of them are around functions that in OTP 20 used very little memory. We are also seeing somewhat frequently what appears to be _negative_ net memory usage, which again seems really strange.</div><div><br></div><div>So, is this some sort of optimization that we're missing, or is there somewhere else (maybe in a heap fragment?) that these structures might be stored? And if they are somewhere else, is it possible to measure this memory usage?</div><div><br></div><div>At the moment we're measuring memory usage by using `erlang:trace/3` to listen to the garbage collection events, and calculate the used memory from there, and adding any remaining used memory on the heap at the end of the function (after the last GC run).</div></div></blockquote><div><br></div><div>Could you please provide a minimal example showcasing the behaviour? I can't think of any optimization done that would explain the change in behaviour.<br></div><div><br></div><div>One thing that you could try is to compile the code using OTP 20 and run in on OTP 21. That way we'll know if it is the compiler that has gotten better, or if the run-time somehow is responsible for the change.</div><div><br></div><div>Lukas</div></div></div>