in reply to [Solved] Perl with Swig C module not releasing memory

You didn't post the outputted C code of SWIG. A WAG says to add "#define NO_XSLOCKS" before the first perl header is included. Perl redefines by preproc malloc and free to its own safesysmalloc and safesysfree.
  • Comment on Re: Perl with Swig C module not releasing memory

Replies are listed 'Best First'.
Re^2: Perl with Swig C module not releasing memory
by megaframe (Novice) on May 10, 2013 at 20:38 UTC

    Sorry. Figured it could be generated from that. I'd post it but it's some 1938 lines of code.

    ...but didn't think to look at that I'll poke around see if I can find out if perl is overwriting the malloc/free functions. Also what's 'WAG'?

      http://en.wikipedia.org/wiki/Wag_%28disambiguation%29

      WAG, an acronym for "wild ass guess", an estimate based on experience or similarity

      Use readmore tags to post long code, dont force the moderators to do it for you. To find out if perl redefined your malloc/free functions, make a .i file from the SWIG outputted .c file. It will be half a MB so don't post the whole thing here, just an function or 2. Your Malloc macro will be expanded to the actual C func symbol that will be called, which might be a perl allocator, not your C compiler's malloc.

        You are correct XSUB.h in the CORE files is what's redefining free() to PerlMem_free and the memory isn't getting released.

        Still trying to figure out how to keep that from happening.