php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5176 Memory leak? Type handling?
Submitted: 2000-06-21 19:51 UTC Modified: 2000-07-24 09:05 UTC
From: slavapl at mailandnews dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (21/06/2000) OS: FreeBSD 3.2/Linux2.2.16
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: slavapl at mailandnews dot com
New email:
PHP Version: OS:

 

 [2000-06-21 19:51 UTC] slavapl at mailandnews dot com
while ( substr($linein = fgets($fs, 4096), 0, 1) != '.' ) { 
	$group_list[] = $linein;
}


This particular bit of code is used to read in a usenet message id listing, each item is 8 characters long (8 bytes??)
The memory usage grows to ridiculous length, for example 11k elements take up 43 megs on my linux 2.2.16 and freebsd 3.2.  

I've been able to hack around the problem using substr like this:

while ( substr($linein = fgets($fs, 4096), 0, 1) != '.' ) { 
	$group_list[] = substr($linein, 0, strlen($linein));
}

this decreased the memory usage to about 4 megs, by a factor of ~10. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-24 01:56 UTC] stas at cvs dot php dot net
So, where's the bug?
 [2000-07-24 09:05 UTC] stas@php.net
fgets taking too much memory - fixed in CVS.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 10:00:02 2026 UTC