I create a simple perl embedding code (copy-paste from documentation):
#include <EXTERN.h> #include <perl.h> static PerlInterpreter * my_perl = 0; int main(int argc, char **argv, char **env) { PERL_SYS_INIT3( &argc, &argv, &env ); my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, 0, argc, argv, 0); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); }

Command line: ./test -e 'print "Hello, world!"'
Works fine, but valgrind report leaks:

==10428== 116 bytes in 15 blocks are definitely lost in loss record 1 +of 2 ==10428== at 0x4A1BDEB: malloc (vg_replace_malloc.c:207) ==10428== by 0x497945: Perl_safesysmalloc (util.c:78) ==10428== by 0x4996C3: Perl_savepvn (util.c:789) ==10428== by 0x42BC24: Perl_gv_fetchpv (gv.c:754) ==10428== by 0x4260CF: S_init_main_stash (perl.c:3510) ==10428== by 0x42034F: S_parse_body (perl.c:1657) ==10428== by 0x420020: perl_parse (perl.c:1598) ==10428== by 0x41D2A6: main (tiny.cpp:12) LEAK SUMMARY: ==10428== definitely lost: 116 bytes in 15 blocks. ==10428== possibly lost: 0 bytes in 0 blocks. ==10428== still reachable: 1,109 bytes in 17 blocks. ==10428== suppressed: 0 bytes in 0 blocks.

1225 leaked bytes on simplest example - not very good. Any ideas?

P.S.: valgrind 3.3.0 - latest release, perl 5.8.8


In reply to Leaks while embedding perl by isemenov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.