[cfe-dev] libclang: Memory management

Jusufadis Bakamovic via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 17 01:01:56 PDT 2017


Interesting. I wasn't familiar with this API. But it looks exactly like
what might be a way to tackle this issue.

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:
    1. Will consume a disproportionaly large amount of memory
    2. Will allocate memory in a way (chunk-wise) that reusing it will be
less probable with other use-cases
    2. Is not recurring
Then I would say that it is safe to use this method to swap the memory back
to the OS.

Thanks,
Adi

On Mar 12, 2017 9:18 PM, "Milian Wolff" <mail at milianw.de> wrote:

> On Freitag, 10. März 2017 20:33:09 CET Jusufadis Bakamovic via cfe-dev
> wrote:
> > Yes, I think there's not much that can be done from libclang POV. This is
> > all memory allocator stuff and should be handled from client code if
> > required but nevertheless interesting observation we should be aware of
> > when building tools.
> >
> > Thanks everybody for the fruitful discussion and details provided.
>
> BTW: If you are unsatisfied with the default behavior of the memory
> allocator,
> you can try to use malloc_trim:
>
> http://man7.org/linux/man-pages/man3/malloc_trim.3.html
>
> Cheers
>
> --
> Milian Wolff
> mail at milianw.de
> http://milianw.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170317/3b689701/attachment.html>


More information about the cfe-dev mailing list