<div dir="ltr"><div dir="auto">Interesting. I wasn't familiar with this API. But it looks exactly like what might be a way to tackle this issue.</div><div dir="auto"><br></div><div>I suppose one should be careful about using it in order not to hurt performance (of follow-up allocations), but if one knows that specific use-case:</div><div>    1. Will consume a disproportionaly large amount of memory</div><div>    2. Will allocate memory in a way (chunk-wise) that reusing it will be less probable with other use-cases</div><div>    2. Is not recurring</div><div>Then I would say that it is safe to use this method to swap the memory back to the OS.</div><div dir="auto"><br></div><div>Thanks,</div><div>Adi</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 12, 2017 9:18 PM, "Milian Wolff" <<a href="mailto:mail@milianw.de" target="_blank">mail@milianw.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Freitag, 10. März 2017 20:33:09 CET Jusufadis Bakamovic via cfe-dev wrote:<br>
> Yes, I think there's not much that can be done from libclang POV. This is<br>
> all memory allocator stuff and should be handled from client code if<br>
> required but nevertheless interesting observation we should be aware of<br>
> when building tools.<br>
><br>
> Thanks everybody for the fruitful discussion and details provided.<br>
<br>
BTW: If you are unsatisfied with the default behavior of the memory allocator,<br>
you can try to use malloc_trim:<br>
<br>
<a href="http://man7.org/linux/man-pages/man3/malloc_trim.3.html" rel="noreferrer" target="_blank">http://man7.org/linux/man-page<wbr>s/man3/malloc_trim.3.html</a><br>
<br>
Cheers<br>
<br>
--<br>
Milian Wolff<br>
<a href="mailto:mail@milianw.de" target="_blank">mail@milianw.de</a><br>
<a href="http://milianw.de" rel="noreferrer" target="_blank">http://milianw.de</a></blockquote></div></div>
</div>