<div dir="ltr">In general: No it won't. GC will trigger once the process has allocated enough data. If your processing is allocating enough data, this will quickly happen and you don't have to worry. If not, you may have to gently persuade the process to do so. There are several ways:<div><br></div><div>* Set fullsweep_after on the process with a low value (0) and run erlang:garbage_collect()</div><div>* Go through a hibernation with an immediate wakeup (feels ugly to me)</div><div>* Handle fetching and extraction in a separate process and send the extracted part 'x' back as a message. This will free up memory almost immediately for other processes to use (simple and elegant)</div><div>* Don't fetch the large object in the first place, but make it possible to ask for an extraction only. Or stream data a bit at a time and handle the stream in chunks rather than everything at once.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 4:11 PM, Eranga Udesh <span dir="ltr"><<a href="mailto:eranga.erl@gmail.com" target="_blank">eranga.erl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm trying to optimize my memory consumption in Erlang VM and to garbage collect as soon as possible.</div><div><br></div><div>Let's say I have a large object, "X", After some processing, I only need to work on small part of X, called "x".</div><div><br></div><div>Can someone advice me if below process flow will put the large object X in to garbage collection, while waiting for the long running job to continue?</div><div><br></div><div><div>function1() -></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">X = ... fetch a large object....</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">... some processing...</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">x = ... extract a part of X...<br>... long running job....<br></blockquote></div></div><div><br></div><div>If it's not putting X into garbage collection, does below change do that?</div><div><br></div><div>function1() -></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>X = ... fetch a large object....</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>... some processing...</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">x = ... extract a part of X...<br>function2(x).<br><br></blockquote>function2(x) -></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>... long running job...</div></blockquote><br></div><div>Tks,</div><div>- Eranga</div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>J.
</div>