php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45296 some string funcs need unexpectedly high memory_limit
Submitted: 2008-06-18 09:12 UTC Modified: 2008-10-29 03:22 UTC
From: louis at steelbytes dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.6 OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: louis at steelbytes dot com
New email:
PHP Version: OS:

 

 [2008-06-18 09:12 UTC] louis at steelbytes dot com
Description:
------------
the following code fails with 

  Fatal error: Allowed memory size of 587896 bytes exhausted (tried to allocate 262145 bytes)

command:
  php.exe -n -f memuse.php

memuse.php:
  @ob_end_flush();
  @ob_implicit_flush(1);
  define('big_size',256*1024);
  define('saftey',4*1024);
  ini_set('memory_limit',memory_get_usage()+big_size*2+saftey);
  $big = str_repeat('x',big_size);

yet if I change big_size to 1024*1024, then it works?


and a simlar script
  @ob_end_flush();
  @ob_implicit_flush(1);
  define('big_size',200*1024);
  define('saftey',4*1024);
  ini_set('memory_limit',memory_get_usage()+big_size+saftey);
  echo str_repeat('x',big_size);

also fails, yet if I change big_size to 180*1024 then it works?


PS, note that in the first script I set mem limit to 2 times big_size, and in the 2nd script I did not.


Reproduce code:
---------------
see above

Expected result:
----------------
see above

Actual result:
--------------
see above

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-28 13:26 UTC] jani@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


 [2008-10-29 03:22 UTC] louis at steelbytes dot com
> but this is not a bug

what is it then?

why can't I use memory_get_usage() + ini_set('memory_limit',xxx) to check for memory leaks in my code?

do I just give up and ini_set('memory_limit',4GigaBytes) and never give a damn about memeory?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 01:01:31 2024 UTC