|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1351 memory leak found in two functions: eval and include
Submitted: 1999-04-27 03:23 UTC Modified: 1999-06-18 11:57 UTC
From: makayg at math dot u-szeged dot hu Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0.7 OS: Linux
Private report: No CVE-ID: None
 [1999-04-27 03:23 UTC] makayg at math dot u-szeged dot hu
This is the test.phtml script:
for ($i=0;$i<5000;$i++)
    echo "$i: ";
// Uncomment one of the following two lines
//    eval("echo 'Hello<BR>\n';");

This is the hello.phtml script:

Uncomment one of the "include" or "eval" lines (the script behaves the same in both cases), then run
     php -f test.phtml
then you will get the following fatal error after about 4095 lines of output:
     Unable to initialize a new token in cache

Checking the memory usage in the whole system, it turns out that this test script quickly fills up about 30 Mb of memory, then stops with the above error. Version 3.0.5 had a similar problem, although it filled up only about 5 Mb, and did not stop after about 4095 lines (I tried with with 100000 in the "for" cycle), but rather filled up all memory the computer had. If I run this script through an Apache module, then in all cases it stops after about 4095 lines. The settings of the php3.ini file seem to be irrelevant, even the memory_limit option. Anyway, I only changed the default configuration in the max_execution_time option, and I included the mysql extension. I downloaded the binary 3.0.5 version from the Debian site, and I compiled the 3.0.7 version with no option (I simply said "./configure").

Since "eval" and "include" behave very similarly, I assume, that the problem is in a subfunction of these functions. There does not seem to be any reason, why these functions should leave memory behind after their run.

I could get rid of "eval" from my program (almost), but I do need "include", I use it to regenerate our WWW pages from templates. 

Please, tell me, if you received this message, or if you have a solution or workaround.

Thank you very much for your attention.

Sincerely yours,

Geza Makay


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-18 11:57 UTC] sas at cvs dot php dot net
As Zeev explained, this won't change in PHP3.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 14 07:01:23 2021 UTC