如何跟踪运行中的PHP进程对象数量?
写了一个脚本用来处理php内存泄漏问题(Linux Support Only):
wget http://gitlab.qima-inc.com/chuxiaofeng/zan-dev-doc/raw/master/zobjdump.sh
chown +x zobjdump.sh
sudo ./zobjdump.sh [pid]
#instances #class
-------------------------------------------
4170 swoole_client
4100 Zan\Framework\Network\Connection\Driver\Tcp
312 Closure
300 Zan\Framework\Network\Connection\Driver\Redis
300 swoole_redis
284 Zan\Framework\Network\Connection\Driver\Mysql
284 swoole_mysql
106 Generator
53 Zan\Framework\Foundation\Coroutine\Scheduler
53 Zan\Framework\Utilities\DesignPattern\Context
53 SplStack
53 Zan\Framework\Foundation\Coroutine\Task
53 Zan\Framework\Foundation\Coroutine\Event
53 Zan\Framework\Foundation\Coroutine\EventChain
51 Zan\Framework\Network\Connection\Driver\Syslog
34 Zan\Framework\Store\Database\Mysql\Mysql2
26 Zan\Framework\Utilities\Types\ObjectArray
19 Kdt\Iron\Nova\Network\ClientContext
19 Zan\Framework\Network\Tcp\RpcContext
19 Zan\Framework\Network\Connection\Driver\NovaClient
19 Kdt\Iron\Nova\Network\Client
13 Zan\Framework\Network\Connection\LoadBalancingStrategy\Polling
13 Zan\Framework\Network\Connection\Pool
13 Zan\Framework\Network\Connection\NovaClientPool
13 Zan\Framework\Network\ServerManager\ServerDiscovery
5 Zan\Framework\Network\Connection\Factory\Redis
5 Zan\Framework\Network\Connection\Factory\Mysql
2 Zan\Framework\Network\Connection\Factory\Syslog
1 Zan\Framework\Foundation\Core\ConfigLoader
1 Zan\Framework\Network\Http\Exception\Handler\InvalidRouteHandler
1 Zan\Framework\Network\ServerManager\ServerDiscoveryInitiator
1 Zan\Framework\Sdk\Monitor\Hawk
......
注意环境依赖
env_check()
{
command -v php >/dev/null 2>&1 || { echo >&2 "php required"; exit 1; }
command -v python >/dev/null 2>&1 || { echo >&2 "python required"; exit 1; }
command -v gdb >/dev/null 2>&1 || { echo >&2 "gdb required"; exit 1; }
if [[ $EUID -ne 0 ]]; then
echo >&2 "root required"
exit 1
fi
if [[ $(rpm -qa|grep '.*php.*debuginfo.*'|wc -l) == 0 ]]; then
echo >&2 "php debuginfo required"
exit 1
fi
}