[erlang-questions] investigating memory issues
Mon Oct 19 13:33:22 CEST 2015
If I understand correctly, you suggest call X = binary:copy(SomeBinary) and
then call jsonx parser with X as parameter? Or just going through parsed
result and then call binary:copy over each binary element?
2015-10-17 13:50 GMT+03:00 Jesper Louis Andersen <
> On Fri, Oct 16, 2015 at 9:34 PM, Caragea Silviu <>
>> 7. jsonx
> This is a shot but I think this library is your problem. When it parses a
> JSON document, it uses enif_make_sub_binary on the binary() containing the
> JSON string. This means if you do not use binary:copy() on data you hoist
> out of the JSON document, then you are keeping the whole document around
> for as long as you refer to that subbinary.
> Try wrapping strings you hoist out in binary:copy/1. This will slow you
> down, but it should remove the reference to the original binary which would
> make your system be able to reclaim that memory. Alternatively, if your
> system is not highly loaded, you could simply replace jsonx for jsx which
> is written in Erlang and avoids such problems (at the expense of slower
> parsing, but JSON will *never* win a parsing race anyway and it is better
> to swtch the format then).
> I've seen systems stuffing such subbinaries into ETS, and then your ETS
> table is keeping data around.
> erlang-questions mailing list
Петровский Александр / Alexander Petrovsky,
Phone: +7 914 8 820 815
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions