[LLVMdev] Possible memory leakage in the LLVM JIT Engine

Graham Wakefield lists at grahamwakefield.net
Sun Mar 22 16:30:33 PDT 2009


Hi,

Was this ever resolved?

I'm curious, I'm also in a situation where there may be many (very  
many) JITted functions over the history of an application (which may  
be running for many days)

Thanks

On Mar 20, 2009, at 7:34 AM, George Giorgidze wrote:

> Hi,
>
> In my application I am JITing thousands of functions, though I am  
> doing it sequantially and running only one at a time. So it is  
> crucial to be able to properly clean up the memory from an old JITed  
> function when JITing and running the new one.
>
> I am using Haskell binding of LLVM and my application works OK.  
> However, memory usage increases and never decreases during the run  
> time of my application. Here is what I do:
>
> 1) I am creating a module
> 2) I am generating an LLVM function and putting it into the module
> 3) creating a module provider for the module
> 4) creating an execution engine for the module provider.
> 5) running the function (using JIT)
> 6) freeing machine code for the function
> 7) deleting the function, module, module provider, exectution engine  
> and all other structures created before
> 8) going to step 1 to JIT a new function
>
> I know that the step number 7 is not really necessary. I tried to  
> use the same execution engine, but memory still leaks. I should note  
> that if interpreter is used instead of JIT no memmory leakage occurs.
>
> Instead of posting my Haskell code, I though it would be better if I  
> post short C++ code that (hopefully) demonstrates the possible  
> leakage. My suspicion is that freeMachineCodeForFunction does not do  
> its job properly.
>
> Let us look at HowToUseJIT.cpp example that comes with LLVM source  
> bundle and let us modify the last lines in the following way:
>
>   for (;;)
>   {
>     gv = EE->runFunction(FooF, noargs);
>     // Import result of execution:
>     outs() << "Result: " << gv.IntVal << "\n";
>   }
>
> Everithing works fine. However if we do the following modification:
>
>   for (;;)
>   {
>     gv = EE->runFunction(FooF, noargs);
>     // Import result of execution:
>     outs() << "Result: " << gv.IntVal << "\n";
>     EE->freeMachineCodeForFunction(FooF);
>     EE->freeMachineCodeForFunction(Add1F);
>   }
>
> It works but a memory usage of the application increases continuously.
>
> So my question is how can I clean up ALL of the memmory created by  
> the JIT engine?
>
> Any pointers to a similar application that succesfully acopmlishes  
> what I want, i.e. does lots of JITing without memory leakage, will  
> be very much appreciated.
>
> Cheers, George
>
> -- 
> George Giorgidze
> http://www.cs.nott.ac.uk/~ggg/
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090322/cc02e567/attachment.html>


More information about the llvm-dev mailing list