I am going to persuade here, since I did not confirm this, but after reading the text of the GC link that you provided, I did not get the impression that memory_get_peak_usage() should return additional information based on the PHP compilation with the DGC_BENCH flag. The manual says that it returns int, so I suspect that it always returns int.
What he will say, however:
When you run the above code again using the newly created PHP binary, you will see what is shown after PHP has finished executing:
It is not very clear, but I have the impression that additional data GC are printed on stdout or stderr , instead of returning to memory_get_peak_usage() or printed as an additional output to your PHP script.
Try calling the new PHP executable from the command line and see if the GC information is passed to the console when the script ends.
You can try calling it like this: /path/to/custom/php testfile.php
I'm not sure it makes sense to output this information if you use PHP as an Apache module or FastCGI handler, so I suspect you can see it by calling a script from the console, but I may be completely wrong.
UPDATE:
I checked that the GC_BENCH compilation flag is still active, and it is.
Zend / zend.c
905 #if GC_BENCH 906 fprintf(stderr, "GC Statistics\n"); 907 fprintf(stderr, "-------------\n"); 908 fprintf(stderr, "Runs: %d\n", GC_G(gc_runs)); 909 fprintf(stderr, "Collected: %d\n", GC_G(collected)); 910 fprintf(stderr, "Root buffer length: %d\n", GC_G(root_buf_length)); 911 fprintf(stderr, "Root buffer peak: %d\n\n", GC_G(root_buf_peak)); 912 fprintf(stderr, " Possible Remove from Marked\n"); 913 fprintf(stderr, " Root Buffered buffer grey\n"); 914 fprintf(stderr, " -------- -------- ----------- ------\n"); 915 fprintf(stderr, "ZVAL %8d %8d %9d %8d\n", GC_G(zval_possible_root), GC_G(zval_buffered), GC_G(zval_remove_from_buffer), GC_G(zval_marked_grey)); 916 fprintf(stderr, "ZOBJ %8d %8d %9d %8d\n", GC_G(zobj_possible_root), GC_G(zobj_buffered), GC_G(zobj_remove_from_buffer), GC_G(zobj_marked_grey)); 917 #endif
Then I compiled PHP 5.3.9 for Apache2 and the CLI. Before deciding to install a test version, I launched a new CLI application for PHP from the console:
./sapi/cli/php -v PHP 5.3.9 (cli) (built: Feb 22 2012 19:03:02) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies GC Statistics ------------- Runs: 0 Collected: 0 Root buffer length: 0 Root buffer peak: 7 Possible Remove from Marked Root Buffered buffer grey -------- -------- ----------- ------ ZVAL 15 7 7 0 ZOBJ 0 0 0 0
It has a GC output, although I did not call PHP. Then I grep'd libphp5.so and saw that it has a bit of GC statistics in it, so I decided to install it live and call from Apache. There is no GC output in the browser, error_log, access_log or any other log files.
Now for the interesting part , I created a test.php file that displays a line and creates frees several variables ...
root@vm :/php539
Output:
When PHP is compiled with the GC_BENCH parameter, you will not have access to the control information when called from the browser or when parsing PHP files using the -f parameter or passing the file name for parsing. You get control information if you call php interactively or run a script through PHP by reading it from stdin .