Re: [PHP-DEV] Trying to find out where the memory went

2011-06-08 Thread Julien Pauli
I wrote about ZendMM some time ago (http://julien-pauli.developpez.com/tutoriels/php/internals/zend-memory-manager/) , that's in french language ;-) To shorten the conversation a little bit, I would suggest to trace the memory with valgrind/massif. That's not too hard if you know what you do, if

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread David Zülke
Please test the exact thing I suggested :) var_dump(memory_get_usage()); token_get_all(file_get_contents(FILE)); gc_collect_cycles(); var_dump(memory_get_usage()); memory_get_peak_usage() is irrelevant, and USE_ZEND_ALLOC won't give accurate results anymore when looking at memory usage. If the

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread Ferenc Kovacs
On Tue, Jun 7, 2011 at 4:28 PM, David Zülke david.zue...@bitextender.comwrote: Please test the exact thing I suggested :) AFAIK he did. int(640720) int(244001144) except if you suggested something else off-list. Tyrael

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread David Zülke
Damn I'm an idiot. I meant memory_get_usage() all along. Sorry Mike. Then it'll make sense... memory_get_usage(), but a gc_collect_cycles() before the second call. So, my first email should have had this code in it: var_dump(memory_get_usage()); token_get_all(file_get_contents('PATH'));

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread David Zülke
One thing to keep in mind of course is that each zval incurs an overhead. $x = 1; requires 144 bytes of memory in total IIRC. David On 04.06.2011, at 23:38, Mike van Riel wrote: Dear Internals, During development of DocBlox I encountered a (for me) unusual situation with regards to

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread Mike van Riel
I have ran the script that you provided and got the following results: int(635192) int(635944) Which is far less than the peak memory result. I use memory_get_peak_usage to measure what the worst case memory output is in my application. I expect this to be the actual memory used (and

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread Mike van Riel
Before I forget; without gc_collect_cycles I get the following output using memory_get_usage instead of memory_get_peak_usage: int(634640) int(635392) Mike On Tue, 2011-06-07 at 19:44 +0200, Mike van Riel wrote: I have ran the script that you provided and got the following results:

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread David Zülke
memory_get_peak_usage() is the maximum amount of memory used by the VM of PHP (but not by some extensions for instance) up until the point where that function is called. So the actual memory usage may be even higher IIRC. But yeah, you're basically right. I've explained in another message why

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread Mike van Riel
Am i then also correct to assume that the output of memory_get_peak_usage is used for determining the memory_limit? Also: after correcting with your new information (zval = 114 bytes instead of 68) I still have a rather large offset: 640952+2165950+114+(276697*114)+(276697*3*114)+2165950 =

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread David Zülke
144 (not 114!) bytes is for an integer; I'm not quite sure what the overheads are for arrays, which token_get_all() produces in abundance :) An empty array seems to occupy 312 bytes of memory. Also, strings have memory allocated in 8 byte increments as far as I know, so 1 eats up 8 bytes, and

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-07 Thread Johannes Schlüter
On Tue, 2011-06-07 at 21:03 +0200, David Zülke wrote: 144 (not 114!) bytes is for an integer; I'm not quite sure what the overheads are for arrays, which token_get_all() produces in abundance :) An empty array seems to occupy 312 bytes of memory. Also, strings have memory allocated in 8 byte

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-06 Thread Mike van Riel
David and Pauli, When I change the test script to: var_dump(memory_get_peak_usage()); gc_collect_cycles(); token_get_all(file_get_contents(FILE)); gc_collect_cycles(); var_dump(memory_get_peak_usage()); And execute the following bash line preceding: export

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-06 Thread Johannes Schlüter
On Mon, 2011-06-06 at 22:30 +0200, Mike van Riel wrote: 1. Does it hurt to disable the Zend MM? 2. Can it be done from inside a PHP Script? 3. Why is the memory consumption so much lower, even lower than my calculations? When you disable Zend MM PHP will not use it but directly the system's

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-05 Thread David Zülke
Smells like a memory leak if gc_collect_cycles() doesn't fix it. David On 05.06.2011, at 00:01, Mike van Riel wrote: Hey David, That gives me the following output: int(640720) int(244001144) Mike On Sat, 2011-06-04 at 23:51 +0200, David Zülke wrote: What does

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-05 Thread Julien Pauli
Seems like leak. Try disabling ZendMM to see if something noticeable happens (memory peak should be lower). USE_ZEND_ALLOC=0 Cheers, Julien On Sun, Jun 5, 2011 at 2:01 PM, David Zülke david.zue...@bitextender.com wrote: Smells like a memory leak if gc_collect_cycles() doesn't fix it. David

[PHP-DEV] Trying to find out where the memory went

2011-06-04 Thread Mike van Riel
Dear Internals, During development of DocBlox I encountered a (for me) unusual situation with regards to memory usage. I hope you can shed some light on this for me as I do not understand. The situations is as follows: I have a php file containing about 53 KLOC (including whitespace and

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-04 Thread David Zülke
What does var_dump(memory_get_peak_usage()); token_get_all(file_get_contents('PATH')); var_dump(memory_get_peak_usage()); get you? David On 04.06.2011, at 23:38, Mike van Riel wrote: Dear Internals, During development of DocBlox I encountered a (for me) unusual situation with regards to

Re: [PHP-DEV] Trying to find out where the memory went

2011-06-04 Thread Mike van Riel
Hey David, That gives me the following output: int(640720) int(244001144) Mike On Sat, 2011-06-04 at 23:51 +0200, David Zülke wrote: What does var_dump(memory_get_peak_usage()); token_get_all(file_get_contents('PATH')); var_dump(memory_get_peak_usage()); get you? David -- PHP