php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40089 memory leak in fgetcsv
Submitted: 2007-01-10 13:29 UTC Modified: 2007-01-10 14:43 UTC
From: zibi at nora dot pl Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.0 OS: linux
Private report: No CVE-ID: None
 [2007-01-10 13:29 UTC] zibi at nora dot pl
Description:
------------
It looks like fgetcsv didn't free memory used for input buffer.

Reproduce code:
---------------
$f=fopen('file.csv','r');
$prev=memory_get_usage();
while($line=fgetcsv($f))
{
  unset($line);
  $now=memory_get_usage();
  echo ($now-$prev);
  $prev=$now;
}


Expected result:
----------------
0
0
0
0
0
0
0
0
0

or something oscilated around 0

Actual result:
--------------
2096
2088
2088
2088
2064
2072
2072
2072
2048
2092

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-10 13:44 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The engine is expected to cache small memory chunks.
All real memory leaks are reported on shutdown.
 [2007-01-10 14:43 UTC] zibi at nora dot pl
Yea, sure. Tell it to my scripts. After parsing more than 20MB csv files scripts are killed cause memory exchaustion (64MB).

I tried to unset everything what is not used, but in every loop execution i loose few kilobytes.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC