Re: memory leaking with closures
On Fri, 07 Sep 2001 18:06:17 +0200, Arthur Bergman wrote: On Fri, Sep 07, 2001 at 12:27:58AM -0700, Alex Krohn wrote: while (1) { { my $var = 'x' x 50; my $sub = sub { my $sub2 = sub { $var; } }; } # $var and $sub should be gone, but memory is never freed sleep 1; # Don't crash things =) } will grow forever it does not grow, definately something strange going on. Happens on perl 5.004_04, 5.005_03 and 5.6.1. confirmed in bleadperl (patch 11936). CCing p5p. atleast one sub { sub{} } leak was fixed recently, but not this one. - Barrie Seems like we are not properly freeing the prototype CV which is cloned. Not likely, since there are always a fixed number of closure prototypes when there is no eval to create new ones. It is more likely that the reference loop between the inner and outer CVs is preventing the freeing of either of them. I'm not in fact sure that the reference loop *can* be eliminated trivially, given these two CVs can have different lifetimes. Perhaps the right solution is to move to using weakrefs for CvOUTSIDE(), I dunno. Sarathy [EMAIL PROTECTED]
Re: [gsar@ActiveState.com: v5.6.1 trial2 is available]
On Tue, 13 Mar 2001 17:10:41 CST, Jarkko Hietaniemi wrote: sorry for not answering sooner. The suggested patch seems to work find with the development branch of Perl, and I believe Sarathy will apply the patch also to the maintenance branch. There is a change in behavior here that looks somewhat suspect because the comments didn't mention it. On Wed, Feb 21, 2001 at 09:32:04PM +0100, Jens-Uwe Mager wrote: +#ifdef USE_NATIVE_DLOPEN [...] +#else [...] +#ifndef RTLD_LAZY +# define RTLD_LAZY 0 +#endif +#ifndef RTLD_GLOBAL +# define RTLD_GLOBAL 0 +#endif [...] -RETVAL = dlopen(filename, 1) ; +RETVAL = dlopen(filename, RTLD_GLOBAL|RTLD_LAZY) ; It seems to me that dlopen() is now being called with a second argument of 0 instead of 1 if USE_NATIVE_DLOPEN wasn't set and those two constants aren't defined in the system headers. Is this an intentional change? Does it have potential to break anything on the pre-4.3 AIX versions? Sarathy [EMAIL PROTECTED]
Re: mod_perl for Apache to work with ActivePerl (APR#816)
On Tue, 18 Jul 2000 11:21:15 PDT, [EMAIL PROTECTED] wrote: Full_Name: Version: ActivePerl 616 OS: Windows NT 4.0 SP 4 or lower Submission from: (NULL) (155.229.70.9) is there a way to get mod_perl for Apache to work with ActivePerl? mod_perl apparently doesn't know anything about ithreads. This patch makes it build and "work" for me, but I haven't tested it for more than 20 seconds. It is possible that similar treatment is needed for other callbacks that my 20-seconds worth of testing did not trigger. :-) Note that the patch should NOT be applied as is. A #ifdef USE_ITHREADS guard is needed around the new code. Sorry I don't have time to make a more complete patch. HTH, Sarathy [EMAIL PROTECTED] ---8--- --- Leak/Leak.xs.dist Wed Aug 02 18:33:34 2000 +++ Leak/Leak.xsWed Aug 02 18:57:38 2000 @@ -121,7 +121,7 @@ { char *state = lookup((struct hash_s **)p, sv, t_new); if (state != t_old) { - fprintf(stderr, "%s %p : ", state ? state : t_new, sv); + PerlIO_printf(PerlIO_stderr(), "%s %p : ", state ? state : t_new, sv); sv_dump(sv); } return hwm+1; --- src/modules/perl/mod_perl.c.distWed Aug 02 18:33:34 2000 +++ src/modules/perl/mod_perl.c Thu Aug 03 13:02:47 2000 @@ -735,9 +735,10 @@ perl_tainting_set(s, cls-PerlTaintCheck); (void)GvSV_init("Apache::__SendHeader"); (void)GvSV_init("Apache::__CurrentCallback"); +#if 0 if (ap_configtestonly) GvSV_setiv(GvSV_init("Apache::Server::ConfigTestOnly"), TRUE); - +#endif Apache__ServerReStarting(FALSE); /* just for -w */ Apache__ServerStarting_on(); @@ -861,10 +862,19 @@ dPPDIR; dPPREQ; dTHR; -GV *gv = gv_fetchpv("SIG", TRUE, SVt_PVHV); +GV *gv; + +dTHX; + +if (!aTHX) { + PERL_SET_CONTEXT(perl); +} (void)acquire_mutex(mod_perl_mutex); - + +gv = gv_fetchpv("SIG", TRUE, SVt_PVHV); + + #if 0 /* force 'PerlSendHeader On' for sub-requests * e.g. Apache::Sandwich @@ -1310,6 +1320,10 @@ I32 i, do_clear=FALSE; SV *sub, **svp; int hook_len = strlen(hook); +dTHX; + +if (!aTHX) + PERL_SET_CONTEXT(perl); if(handlers == Nullav) { if(hv_exists(stacked_handlers, hook, hook_len)) { End of Patch.