[erlang-questions] How to examine binaries identified by erlang:memory/2?

Hynek Vychodil vychodil.hynek@REDACTED
Tue Mar 17 10:28:18 CET 2009

I have thought about same. It is unpleasant feature.

On Tue, Mar 17, 2009 at 6:50 AM, Scott Lystig Fritchie <
fritchie@REDACTED> wrote:

> Paul Fisher <pfisher@REDACTED> wrote:
> pf> My question: Is there any way to identify the "leaked" binaries?  If
> pf> I could look at a few, it would probably be enough to figure out the
> pf> culprit immediately.
> Not that I'm aware of.  However, I can suggest at least one place to
> start looking.  (I've been bitten by this, very unpleasant, yes.)
> If I'm not wildly mistaken (and I could be, I really should be asleep
> right now), then doing this a few thousand times will "leak" a lot of
> memory, apparently in binaries.
>    BigBin = list_to_binary(lists:duplicate(10*1024*1024, $x)),
>    <<_:8777666/binary, Desired:90/binary, _/binary>> = BigBin,
>    ets:insert(SomeTable, {SomeKey, ..., Desired, ...}),
> IIRC, according to section 4.1 of the Erlang Efficiency Guide, BigBin
> will be a reference counted binary.  Desired will be a sub binary.  Both
> will refer to the 10 MBytes in BigBin's blob area thingie handwaving
> really- ought-to-go-to-sleep.  BigBin's ref count will be two and will
> drop to one after BigBin is GC'ed, but it won't drop to zero until the
> reference buried in the SomeTable ETS table goes away.
> If I've mangled the details, I hope a soul both enlightened and
> wide-awake can correct me.
> -Scott
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill your
boss.  Be a data hero!
Try Good Data now for free: www.gooddata.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090317/ec0f2bb0/attachment.htm>

More information about the erlang-questions mailing list