Bug #10204 Updated: fgets causes memory leaks
| From: | sniper@php.net | Date: | Tue, 02 Oct 2001 22:10:21 +0000 |
| Subject: | Bug #10204 Updated: fgets causes memory leaks | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-67125@lists.php.net to get a copy of this message | ||
ID: 10204
Updated by: sniper
Reported By: pallmall@hushmail.com
Old Status: Feedback
Status: Closed
Bug Type: Sockets related
Operating System: Linux, BSD and Windows
PHP Version: 4.0 Latest CVS (06/04/2001)
New Comment:
No feedback. Please reopen if problem still exists with latest CVS. And compile it with
--enable-debug before reopening. And add the possible log entries here.
--Jani
Previous Comments:
------------------------------------------------------------------------
[2001-09-09 06:12:08] sterling@php.net
Can you compile php with --enable-debug, this should report
all leaks, if there are any...
------------------------------------------------------------------------
[2001-04-09 11:22:55] pallmall@hushmail.com
> I am in the process of working on a file abstraction for this stuff, so it will be rewritten.
Hmm. I'm already using an abstraction layer; Net_Socket from PEAR. I had to modify the readLine
method to read a byte at a time until it encounters \n to workaround the fgets bug.
> Maybe I haven't looked hard enough. Please let me know if $page = null works around the
> problem for now.
No it doesn't.
------------------------------------------------------------------------
[2001-04-09 07:57:22] wez@php.net
Sorry - I somehow missed the unset.
However, unset just removes the variable from the symbol table - try using $page = null instead.
I am in the process of working on a file abstraction for this stuff, so it will be rewritten.
The wierd thing is that I really can't see why fgets would behave differently from fread.
Maybe I haven't looked hard enough.
Please let me know if $page = null works around the problem for now.
------------------------------------------------------------------------
[2001-04-09 07:29:57] pallmall@hushmail.com
> Um, yes, the memory usage increases because you are appending an infinite number of copies
of the google page to your $page variable.
No, that's what the unset is for.
Anyways, here's memory statistics.
On loading script one: 3740kb RAM used after two iterations (RAM should not increase above this
level).
After 5 minutes: 4130kb.
Cf script two: 3752kb RAM used initially, and 3752kb after 5 minutes.
These statistics aren't especially dramatic, but in other conditions it can be catastrophic.
Regarding fclose, no this doesn't help.
There is a problem with fgets but not fread.
------------------------------------------------------------------------
[2001-04-09 06:58:37] pallmall@hushmail.com
> Um, yes, the memory usage increases because you are appending an infinite number of copies
of the google page to your $page variable.
No, that's what the unset is for.
Anyways, here's memory statistics.
On loading script one: 3740kb RAM used after two iterations (RAM should not increase above this
level).
After 5 minutes: 4130kb.
Cf script two: 3752kb RAM used initially, and 3752kb after 5 minutes.
These statistics aren't especially dramatic, but in other conditions it can be catastrophic.
Regarding fclose, no this doesn't help.
There is a problem with fgets but not fread.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10204
Edit this bug report at http://bugs.php.net/?id=10204&edit=1