1> X = myserver:start_link("/tmp/1.cache").
{ok,<0.33.0>}
2> myserver:info().
{binary,[{140408119021616,401681797,2}]}
3> myserver:release().
ok
4> myserver:info().
{binary,[{140408119021616,401681797,2}]}
7> memory(binary).
402043632
How come there are 2 references on it and what to do to free this binary?
--
Best Regards,
Volodymyr Kyrychenko
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
handle_call(info, _From, State) ->
erlang:garbage_collect(),
{reply, process_info(self(), binary), State};
// Björn-Egil
To be a little more specific. The references (Procbins) to your offheap
binary are still on the process heap even though nothing in the rootset
is referencing the procbins. A gc will be triggered when the current
heap is full, binary vheap is "full" or an explicit garbage_collect is
called for, which ever comes first. At that moment the procbins will be
removed and the offheap binary will be deallocated (if nothing else is
referencing it).
// Björn-Egil
I really thought that hibernating should make full cleanup of process state.
A = crypto:rand_bytes(1024*1024*1024),
erlang:garbagecollect(),
{reply, ok, State}
Will gc free A? I think that no, because A is still used in the place,
where gc is called. Am I right?
I thought, that calling gc will be a problem:
A = crypto:rand_bytes(1024*1024*1024),
erlang:garbagecollect(),
{reply, ok, State}
Will gc free A? I think that no, because A is still used in the place,
where gc is called. Am I right?
Is this an artifact of the current implementation?Semantically, I don't see why a sufficiently smart VM wouldn't be able to collect the binary at that point.