[LLVMdev] Prevent unbounded memory consuption of long lived JIT processes

NAKAMURA Takumi
2011-03-16T01:39:41Z

Good morning Jose,

Thank you to send patches.

  - Please send patches to llvm-commits.
  - Please make patches with "--attach". You may add
"format.attach"
to git config.

I have not seen yours yet, but I pushed yours to github;
https://github.com/chapuni/LLVM/compare/ed4edf9e...jfonseca%2F20110316
(Excuse me I could not input accent)

...Takumi


On Wed, Mar 16, 2011 at 8:15 AM,  <jfonseca at vmware.com>
wrote:
> This series of patches address several issues causing memory usage to grow
> indefinetely on a long lived process.
>
> These are not convenional leaks -- memory would have been freed when the
LLVM
> context or/and JIT engine is destroyed -- but for as long as they
aren't the
> memory is usage effectively ubounded.
>
> The issues were found using valgrind with '--show-reachable=yes'
option:
> 1. Compile a bunch of functions with JIT once; delete the result; and exit
>   without destroying LLVM context nor JIT engine. (valgrind will report a
>   bunch of unfreed LLVM objects)
> 2. Do as 1, but compile and delete the functions twice
> 3. Ditto three times.
> 4. Etc.
>
> Flawless code should not cause the memory usage to increase when compiling
the
> same -- ie valgrind's log for every run should show the very same
unfreed
> objects, regardless of the number of times a given code was compilation,
but
> that was not the case. The attached patches cover most of the causes for
new
> objects being allocated.
>
> It should be possible to automate such test, but I didn't get that far.