Dirkjan Bussink
2013-Jan-20 14:54 UTC
[LLVMdev] Memory clean for applications using LLVM for JIT compilation
On 14 Jan 2013, at 15:48, Reid Kleckner <rnk at google.com> wrote:> > Or maybe would it be possible to have a custom allocator for memory space for the native code that we could provide? With this last option we would be responsible for the clean up ourselves and just provide memory space to LLVM where it can store the results. > > Yes, you should be able to inherit from llvm::JITMemoryManager and do something like this.I've been trying to work with this solution, but it does pose a problem. The problem is that we use an ExecutionEngine and set a memory manager with setJITMemoryManager on EngineBuilder. The problem is that this means when the ExecutionEngine is deallocated, it end up deallocating the memory manager. I can understand doing this when the code sets up it's own memory manager, but with an external memory manager, I'd expect LLVM not to deallocate that object for me. Is there a way to prevent this from happening? I can't keep the ExecutionEngine around here either, since EngineBuilder needs a Module, which in it's turn needs an LLVMContext, which I'm trying to create for each new request. Does anyone have additional ideas for how to handle this? Or whether there is another approach that could work here? -- Dirkjan
Manny Ko
2013-Apr-04 13:27 UTC
[LLVMdev] Memory clean for applications using LLVM for JIT compilation
Yeah, the JITMemoryManager appears to be owned by the EE and I cannot find a way to get around it. I agree from an API design point of view a custom mgr should be owned by the client code but that is not how it works right now. You probably have to copy out the JIT code into your own block of memory. ________________________________________ From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] on behalf of Dirkjan Bussink [d.bussink at gmail.com] Sent: Sunday, January 20, 2013 6:54 AM To: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Memory clean for applications using LLVM for JIT compilation On 14 Jan 2013, at 15:48, Reid Kleckner <rnk at google.com> wrote:> > Or maybe would it be possible to have a custom allocator for memory space for the native code that we could provide? With this last option we would be responsible for the clean up ourselves and just provide memory space to LLVM where it can store the results. > > Yes, you should be able to inherit from llvm::JITMemoryManager and do something like this.I've been trying to work with this solution, but it does pose a problem. The problem is that we use an ExecutionEngine and set a memory manager with setJITMemoryManager on EngineBuilder. The problem is that this means when the ExecutionEngine is deallocated, it end up deallocating the memory manager. I can understand doing this when the code sets up it's own memory manager, but with an external memory manager, I'd expect LLVM not to deallocate that object for me. Is there a way to prevent this from happening? I can't keep the ExecutionEngine around here either, since EngineBuilder needs a Module, which in it's turn needs an LLVMContext, which I'm trying to create for each new request. Does anyone have additional ideas for how to handle this? Or whether there is another approach that could work here? -- Dirkjan _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reasonably Related Threads
- [LLVMdev] Memory clean for applications using LLVM for JIT compilation
- [LLVMdev] Memory clean for applications using LLVM for JIT compilation
- [LLVMdev] Memory clean for applications using LLVM for JIT compilation
- [LLVMdev] Memory clean for applications using LLVM for JIT compilation
- [LLVMdev] Memory clean for applications using LLVM for JIT compilation