Dubious about the {memory_usage} figure being reported |
[eluser]jedd[/eluser]
I'm seeing weirdness, and I suspect it's down to the way that PHP measures this - as I gather the templaty {memory_usage} output is just a wrapper around an extant PHP function. A script that pulls in a 9.7MB xml file, and then churns around with it - duplicating probably 90% of it, and doing things like extracting and sorting through 23,000 arrays within that data structure, as well as various other HTML view rendering and so on - smugly reports, on completion, that it only used 1.3MB. This is extra dubious because when my php.ini was set to allow 64MB process limit, I was getting errors - and had to bump it up to 100+. I'm not hugely fussed about this, though it'd be nice to a) understand where the confusion lies, and b) have a clearer idea of actual memory usage while I'm developing.
[eluser]jedd[/eluser]
php 5.2.11 ci 1.7.2 apache 2.2.14 linux kernel 2.6.30 debian unstable
[eluser]BrianDHall[/eluser]
You are correct on your wrapper suspicion, jedd. From profiler.php: Code: if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') http://php.net/manual/en/function.memory-get-usage.php I suspect this might be a good part of the oddness: Quote:Description I must admit I don't know what the hell emalloc() is or what the difference in 'real' memory usage is and this, but I bet it goes a long way to explaining your results.
[eluser]jedd[/eluser]
Hmm, almost sounds like the function default is around the wrong way. I found [url="http://marc.info/?l=php-internals&m=103334006314248&w=2"]this email[/url] from Rasmus himself! - describing emalloc / malloc differences. Quoting from that post: Quote:malloc() is the normal system malloc() and emalloc() is a #define which points to He has a caveat regarding third party libraries needing malloc calls to be safe, and this was posted in 2002 .. draw your own conclusions there. In any case, it's probable that the guts of PHP uses emalloc for the most part - or at least did up until 2002 - and consequently the default memory_get_usage() function should be mostly insightful. I might play around with the php functions a bit more and see if I can glean something useful. |
Welcome Guest, Not a member yet? Register Sign In |