Hi, I'm trying to write a persistent perl daemon, but have noticed what
looks like a memory leak, with perl_parse.

It only seems to occur once dynamic loading of perl modules is enabled, here
is my test kit:

code in showtime.c:

#include <EXTERN.h>
#include <perl.h>
#include <stdio.h>

EXTERN_C void xs_init(pTHX);

int main(int argc, char **argv, char **env) {
        char *args[] = { NULL };
        PERL_SYS_INIT3(&argc,&argv,&env);
        int j;
        for(j=100000; j>0; --j) {
                PerlInterpreter *my_perl = perl_alloc();
                perl_construct(my_perl);

                perl_parse(my_perl, xs_init, argc, argv, NULL);
                PL_exit_flags |= PERL_EXIT_DESTRUCT_END;

                perl_destruct(my_perl);
                perl_free(my_perl);
        }
        PERL_SYS_TERM();
}

to compile:

# perl -MExtUtils::Embed -e xsinit
# cc -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`
# cc -c showtime.c `perl -MExtUtils::Embed -e ccopts`
# cc -o showtime perlxsi.o showtime.o `perl -MExtUtils::Embed -e ldopts`

To run:

# ./showtime -e "use Time::HiRes;" &
# watch -d ps u $!

Notice RSS size keeps on getting larger, 20k/sec
Works with other modules aswell

# perl -v

This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

This wouldn't be a problem normally as I could simply dump the process after
x calls, however writing this into a pthreaded app makes it very hard to
dump & recreate the process.

I've run valgrind over it, and it cannot find any memory leaks..

Any help would be much appreciated..

Cheers

James Shirley

Reply via email to