Rules regarding the refcount of binaries

John Haugeland <>
Wed Jun 3 17:48:23 CEST 2009


Sorry about the message fragment a second ago.  Google mail on the
iPhone is brutal.  If someone with list control can step in in time to
destroy it, please do.

Are the rules for when binaries are reference counted and what the
results thereof are well documented somewhere?  Several threads on
this mailing list have implied that the use of large binaries in
programs has led to what appear to be memory leaks, which in turn
suggests that refcounted binaries aren't destroyed when their
reference count hits zero.  At the same time, that seems to present
many unlikely practical problems: for example, it seems remarkably
unlikely that gen_tcp in binary mode would deliver refcounted
binaries, since that'd be a monstrous memory leak if they weren't
cleaned up.

Alternately, is there a way to specify that a given binary is not to
be refcounted?  If I can do that, then I don't need to know the
surrounding rules.

Even more alternately, can I just turn off refcounting for a given VM somehow?

I'm in a position where working with binaries is the clear correct
approach, but if they get refcounted and there's no way to either
suppress that or manually un-refcount them, then the VM's going to run
out of memory reliably every several hours, which obviously isn't
tolerable.

Thanks for any help in advance.


More information about the erlang-questions mailing list