[Chameleon] Interference with PHP's Garbage Collection

Delfos, Jacob Jacob.Delfos at maunsell.com
Tue May 9 18:48:46 EDT 2006


I didn't realise Chameleon had a function for this. I have always used
an application I built for this (I suppose it reduces the overhead of
garbage collection).

I guess the reason I never realised is because the default probability
of garbage collection occuring on the start of a session is 1 in 1000.

Abe, try playing with the "session.gc_probability" in php.ini.

Regards,

Jacob
 

> -----Original Message-----
> From: chameleon-bounces at lists.maptools.org 
> [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of 
> Julien-Samuel Lacroix
> Sent: 10 May 2006 01:22
> To: Abe Gillespie
> Cc: chameleon at lists.maptools.org; Bart van den Eijnden (OSGIS)
> Subject: Re: [Chameleon] Interference with PHP's Garbage Collection
> 
> Hi,
> 
> Are you on Windows or Linux?
> 
> Here's the garbage collection function. Do you see any problem in it? 
> First thing can be to set bDebug to true  and the szDebugDir 
> at the top 
> of chameleon/htdocs/common/session/session.php
> 
> Julien
> 
> /**
>   * _gc Called by PHP session manager when a session is started or
>   * register (not all the time) depending og session.gc_probability
>   */
> function _gc($nMaxLifeTime)
> {
>     if ($GLOBALS["bDebug"])
>      {
>        debug_msg("_gc called");
>      }
>      if ($GLOBALS['gszGarbageColectionCallBackFunction'] != "")
>      {
>          if 
> (function_exists($GLOBALS['gszGarbageColectionCallBackFunction']))
>              eval($GLOBALS['gszGarbageColectionCallBackFunction']);
>      }
> 
>      if ( !(PHP_OS == "WINNT" || PHP_OS == "WIN32") )
>      {
>        @touch($GLOBALS['gszSessSavePath']."/deleteme", 
> time()-$nMaxLifeTime*60);
>        system("find ".$GLOBALS['gszSessSavePath']." -name 
> sess_* ! -newer ".
>               $GLOBALS['gszSessSavePath']."/deleteme -exec rm 
> -rf {} \; ");
> 
>        return true;
>      }
> 
>      $bReturn = true;
> 
>      if (!$hDir = @opendir($GLOBALS['gszSessSavePath']))
>      {
>          return false;
>      }
> 
>      while($szFile = readdir($hDir))
>      {
>          if (!strstr($szFile,'sess_'))
>              continue;
> 
>          if (strpos($szFile,'sess_') != 0)
>              continue;
> 
>          $szSessionDir = $GLOBALS['gszSessSavePath']."/".$szFile;
>          $szSessionFile = $szSessionDir."/session_file";
> 
>          if (!($mtime = @filemtime($szSessionFile)))
>          {
>              $bReturn=false;
>              continue;
>          }
> 
>          if (time() > $mtime + $nMaxLifeTime)
>          {
>              $bReturn = (deleteDirectory($szSessionDir)) ? 
> $bReturn : false;
>          }
>          closedir($hDir);
> 
>          return $bReturn;
>      }
> }
> 
> 
> 
> Abe Gillespie wrote:
> > I'm afraid I will have to do that myself.  I like to stick with
> > built-in (i.e. "supported") technology where I can.  I might not be
> > able to in this case.
> > 
> > Thanks for the help though.  Anyone else wanna chime in?
> > 
> > -Abe
> > 
> > On 5/9/06, Bart van den Eijnden (OSGIS) <bartvde at xs4all.nl> wrote:
> > 
> >> Abe,
> >>
> >> we use a shell script to clean out the files instead.
> >>
> >> Best regards,
> >> Bart
> >>
> >> Abe Gillespie wrote:
> >>
> >> > I'm trying to pin down a problem with PHP's session tmp directory
> >> > growing out of control.  The problem grabbed my attention when a
> >> > customer's server ran out of space.  At that point the session
> >> > directory was 13.5G!
> >> >
> >> > I set the probability of garbage collection to 100 / 100 ... or
> >> > "always collect."  This has not helped since I see files 
> beyond the
> >> > default age of 1440 seconds.
> >> >
> >> > Anyone else experiencing this or have a clue what I'm missing?
> >> >
> >> > System:
> >> > The only PHP app is Chameleon.
> >> > Chameleon 2.2
> >> > Apache 2.0.54
> >> > PHP 4.4.0
> >> >
> >> > All php.ini settings are default as included with 
> php.ini.recommended
> >> > except for:
> >> > session.gc_probability = 100
> >> > session.gc_divisor     = 100
> >> >
> >> > Help is greatly appreciated.
> >> > -Abe
> >> >
> >> > _______________________________________________
> >> > Chameleon mailing list
> >> > Chameleon at lists.maptools.org
> >> > http://lists.maptools.org/mailman/listinfo/chameleon
> >> >
> >> >
> >>
> >>
> >> -- 
> >> Bart van den Eijnden
> >> OSGIS, Open Source GIS
> >> http://www.osgis.nl
> >>
> >>
> > 
> > _______________________________________________
> > Chameleon mailing list
> > Chameleon at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/chameleon
> 
> -- 
> Julien-Samuel Lacroix
> Mapgears
> http://www.mapgears.com/
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 



More information about the Chameleon mailing list