php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16564 Get size of memory allocated in script
Submitted: 2002-04-12 06:51 UTC Modified: 2002-04-12 11:29 UTC
From: marv at cyberia dot net dot lb Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.2 OS: Any
Private report: No CVE-ID: None
 [2002-04-12 06:51 UTC] marv at cyberia dot net dot lb
I'm developing code libraries for use in web projects. Its important that the code be memory effecient, but there is no way to track this currently.

The way php handles objects and arrays it's hard to know when copies are being made internally. As I understand it, if you have $a=$b in your script, if $b is an object or array, its not actually copied. Only if there was a change in one of the elements through $a, does the the object get copied and the change applied on the copy.

So it would be very useful to have a function that reports on the internal memory allocations being made by a script, so we one can track if excessive copying is being made.

Just returning the size would be good enough. Being able to get it in categories (ie. resources, arrays, objects, references) would be fantastic.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-12 11:29 UTC] rasmus@php.net
If you build PHP with --enable-memory-limit then PHP will write the peak memory usage of the script to the "mod_php_memory_usage" Apache note.  You can then have this logged in your Apache log file by adding {mod_php_memory_usage}n to your log format string.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 12:01:29 2024 UTC