php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71349 Garbage collection not running
Submitted: 2016-01-12 11:03 UTC Modified: 2016-08-30 10:19 UTC
From: yunosh@php.net Assigned: yunosh (profile)
Status: Closed Package: Session related
PHP Version: master-Git-2016-01-12 (Git) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yunosh@php.net
New email:
PHP Version: OS:

 

 [2016-01-12 11:03 UTC] yunosh@php.net
Description:
------------
Looks like the GC settings don't work properly, or GC doesn't work at all on 7.1.0-dev.

Test script:
---------------
ini_set('session.gc_probability', 100);
ini_set('session.gc_divisor', 1);
ini_set('session.gc_maxlifetime', -1);
session_name('sessionname');
@session_start();


Expected result:
----------------
All sessions should be GC'ed

Actual result:
--------------
They aren't.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-12 12:00 UTC] yunosh@php.net
Test with unit tests:

$ sudo pear -d auto_discover=1 install -o -f channel://pear.horde.org/Horde_SessionHandler channel://pear.horde.org/Horde_Db channel://pear.horde.org/Horde_Test
$ php $(pear config-get test_dir)/Horde_SessionHandler/Horde/SessionHandler/AllTests.php
 [2016-08-27 06:29 UTC] yohgaki@php.net
-Status: Open +Status: Feedback
 [2016-08-27 06:29 UTC] yohgaki@php.net
I don't see problem with current PHP-7.0/7.1 branches. 

Are you sure your system is using other save handlers like memcache, etc?
Use following script. You should see undefined var error always if PHP is working correctly.

<?php
error_reporting(-1);
ini_set('session.save_handler', 'files');
ini_set('session.save_path','/tmp');
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
ini_set('session.gc_maxlifetime', -1);
session_name('sessionname');
var_dump(session_start());
$_SESSION['cnt']++;
 [2016-08-27 06:30 UTC] yohgaki@php.net
Are you sure your system is NOT using other save handlers like memcache, etc?
 [2016-08-30 10:19 UTC] yunosh@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: yunosh
 [2016-08-30 10:19 UTC] yunosh@php.net
Looks like this has been fixed in the meantime.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 23:01:36 2025 UTC