[EMAIL PROTECTED] said:

Hardly a beginners question :-)  But anyway:

> Hi  ,
>           I found memory leak with  the perl API  "perl_eval_sv"  .
>           Iam attaching the c code that i used as a sample  to come to the
> conclusion that the
>           api "perl_eval_sv"  has got memory leaks .
>           Iam  stuck with this .
>           Could you suggest some way out of this ?

You have forgotton to mention anything about your environment.  At least
the version of perl you are running would be useful, and preferably the
whole output from perl -V.

> #include <EXTERN.h>
> #include <perl.h>
>
> static PerlInterpreter *my_perl;
> int main (int argc, char **argv, char **env)
>    {
>        char *embedding[] = { "", "-e", "0" };
>
>        my_perl = perl_alloc();
>        perl_construct( my_perl );
>
>        perl_parse(my_perl, NULL, 3, embedding, NULL);
>        perl_run(my_perl);
>         SV* sv = newSVpv("Hello",0);
>         while(1)
>         {
>        perl_eval_sv(sv, G_VOID | G_DISCARD);
>         }
>        perl_destruct(my_perl);
>        perl_free(my_perl);
>    }
>
> The above code leaks memory which increases by 8k in every 5 minutes .

As it happens, I believe this particular leak is fixed by a patch I sent
in just last week :-)  If you are interested in the details, one op in
every 65536 leaks because the op sequence number wraps around, and 65535
(-1) is a magical number the compiler backend uses to flag ops that should
not be freed.

So, if that is the case you have three options:

  - grab a copy of bleadperl (the development sources), where the patch
has     already been applied

  - grab a copy of my patch and apply it to whatever version of perl you  
      choose (look for my recent posts in the p5p archives)

  - not worry about it, after all, for how much of its life will your     
   program be allocating opcodes, and even allocating at top whack,
you're     only leaking 8k every 5 minutes.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to