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

jfonseca at vmware.com jfonseca at vmware.com
Tue Mar 15 16:15:50 PDT 2011


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.




More information about the llvm-dev mailing list