Page 1 of 1

Garbage Collection Help Needed! :(

Posted: Thu Mar 06, 2003 9:55 am
by pj
Hello everyone,
when I first installed PHP on my server, i set the 'session.auto_start=' definition to 1.
Now I have the following problem.... Each *.php page after refresh creates a new '0' (zero) size session file, and seems, that the garbage collector does not clean them.
How to deal with it?
Any ideas are apreciated!
10x in advance.
pj

Posted: Thu Mar 06, 2003 8:18 pm
by Stoker
garbage collection is really something else, and generally not needed in PHP scripts, although the PHP website also refers to "session data cleaning" as garbage collection as well..

.. if you enabled auto-session I believe that is the same as a session_start() for all pages, so your session-dir will fill up with some amount of files, according to http://www.php.net/manual/en/ref.session.php PHP will use the session.gc_maxlifetime setting as lifetime of session data, if this is set high your files will stay there for a while and probably pile up on busy sites.. The manual also notes that the filesystem must keep track of access-time, and some Bill Gates file systems doesn't, so if you are on windows that may be the reason..

Posted: Fri Mar 07, 2003 2:42 am
by pj
Hi Stoker,
Thanks for the prompt reply!

Well, I'm on Linux Slackware and PHP4. I do use session.auto_start rather than putting on each separate page session_start() in order to save some coding time. The point is, that when User is logged and after that logged out the session containing the 'user data' is removed from the file system, but those sessions with no data at all continue to stay. I presume when the site is ready it will be quite busy and I will find my self in situation of permanent "garbage collection". This is what I need to avoid. The '0' size files are those I need to remove from the system.

Thanks again.
BRGDS.
pj

Posted: Fri Mar 07, 2003 8:19 am
by Stoker
I am guessing that when a user logs out you use a session_destroy() or similar and that will delete the session file, while thos that where never logged in still have a session so they never get a session_destroy, and those files will live as long as the timeout is set..