[llvm-dev] MCJit and remove module memory leak?

koffie drinker via llvm-dev
Sun, 06 Nov 2016 18:30:20 -0000

I Lol'ed at your commit msg :)
We will start migrating to ORC for next release, but for now, this release
invoke delete after remove right?

On Sat, Nov 5, 2016 at 12:20 AM, Lang Hames <lhames at gmail.com> wrote:

> Hi Koffie,
>
> Kaleidoscope is no longer using MCJIT - it has been moved over to the
> ORC-based KaleidoscopeJIT class (see
llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h).
> The removeModule method there does not leak memory.
>
> I've added documentation in r286026 to describe MCJIT
removeModule's crazy
> ownership contract.
>
> This will be fixed properly when we kill off ExecutionEngine. :)
>
> - Lang.
>
>
> On Fri, Oct 28, 2016 at 4:10 AM, koffie drinker <gekkekoe at
gmail.com>
> wrote:
>
>> I'm on llvm 3.8.1 and was wondering if there's a memory leak in
the
>> removeModule impl of mcjit.
>> In the tutorial http://llvm.org/releases/3.8.1/docs/tutorial/LangIm
>> pl4.html a module is removed from the Jit by invoking removeModule.
>>
>> According to the tutorial:
>>
>> "Its API is very simple:: addModule adds an LLVM IR module to the
JIT,
>> making its functions available for execution; removeModule removes a
>> module, freeing any memory associated with the code in that
module;"
>>
>> But when I look into the implementation of remove module, it only
erases
>> the ptr from AddedModules
>> //return AddedModules.erase(M) || LoadedModules.erase(M) ||
>> FinalizedModules.erase(M);
>>
>> When you add a module, the unique ptr is stripped, and the raw ptr is
>> stored.
>> //AddedModules.insert(M.release());
>>
>> This should imply that the person who is invoking removeModule also
>> should invoke a delete on the ptr?
>>
>> Am I missing something here?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20161106/3628d434/attachment.html>