在開發 PHP 時,如果用了 MVC 架構,又加入了一大堆有的沒的 Library 時,要找出效能瓶頸,XDebug 是頗好用的。
但是在 2.x 版之後的 XDebug 把 memory profiling 拿掉了… (http://www.xdebug.org/updates.php)
所以如果要看哪個 function 吃掉大量記憶體,就需要靠別的工具了!!
測試了一些方法,發現 php-memory-profiler (https://github.com/arnaud-lb/php-memory-profiler) 是挺好用的
以下介紹一下安裝設定方式:
先安裝 php-pear, cc, gcc 用來 compiler php-memory-profiler
yum install php-pear cc gcc make
透過 PECL 安裝
pecl install memprof