|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-06-03 14:42 UTC] johannesdahse at gmx dot de
Description:
------------
The memory usage functions memory_get_usage() and memory_get_peak_usage() are limited by INTEGER and can only store the memory usage of 2.147 GB. This results in false reports for higher memory usage.
Tested on Windows 7 64bit, PHP 5.5.13 (64bit and 32bit version).
Test script:
---------------
ini_set("memory_limit", "3G");
$a = array();
for($i=0; $i<22; $i++)
$a[$i] = str_repeat("A", 100000000);
echo memory_get_peak_usage();
Expected result:
----------------
2200227928
Actual result:
--------------
-2094739216
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
You can increase the limit by using the negative integer. $bytes = memory_get_peak_usage(); if($bytes < 0){ $bytes = PHP_INT_MAX + ($bytes - ~PHP_INT_MAX); }