[erlang-questions] Any guidance on tweaking allocator settings?
Fri Apr 8 18:56:22 CEST 2016
On 04/08, Jordan Day wrote:
>Hi Metin, Fred, Lukas,
>In a long-running process, I’m recursively calling into my function
>for downloading a bunch of these JSON documents in what I *think* is a
>tail-recursive manner, but I’m guessing I’m doing something that’s keeping
>the memory from being freed during the recursion. When I instead spawn a
>new process that fetches a single JSON document, parses it, and then dies,
>I see memory (in top) spike by 100-200 mb, but settle back down fairly
>quickly after the process terminates.
One thing here that may be at play is how large the original JSON is. If
what you're doing is parsing, say, 10 characters out of a 20MB JSON,
what you may get is a slice off a off-heap binary that keeps the
references alive and keeps the large JSON from ever being deallocated.
Pick the fields you want and call `binary:copy(Bin)` to get a smaller
verson disjoint from the large one.
This may be enough to let the VM free memory from that point on.
More information about the erlang-questions