Memory allocated for JIT compiled code


I am looking for ways to reduce the memory consumption in my JIT
compiler that uses LLVM. In my implementation a compiled function
lives in its own module. After compiling the function/module I would
like to be able to discard any memory associated with the module but
retain the compiled code. How can I do this?

I am currently using MCJIT but if the new ORC API supports this then I
will be happy to migrate to it.

Thanks and Regards


Hi Dibyendu,

I’d recommend trying ORC out - it gives you a lot more flexibility in your memory management, and aggressively frees memory by default.

If you haven’t used ORC before I’d check out the tutorials under llvm/examples/Kaleidoscope/Orc. The basic JIT in the ‘initial’ tutorial should be all you need to replace MCJIT in most cases.