这里写问题描述
运行一段时间后内存一直涨 每个php进程大概100M 请问正常吗
$worker = new Worker();
$worker->count = 10;
$worker->name = 'OPRE';
$worker->onWorkerStart = function ($worker) {
self::$options['client_id'] = "OP-PHP-SERVICE-" . uuid();
$mqtt = new \Workerman\Mqtt\Client(self::$host, self::$options);
$mqtt->onConnect = function ($mqtt) {
$mqtt->subscribe('$queue/test/test/+/+/+/+/+/report', array('qos' => 0), function ($exception, $granted) {
if ($exception) {var_dump($exception);} else {var_dump('aaa', $granted);}
} );
$mqtt->subscribe('$queue/test/test/+/+/+/+/+/response', array('qos' => 0), function ($exception, $granted) {
if ($exception) {var_dump($exception);} else {var_dump('aaa', $granted);}
} );
//订阅设备上下线状态
$mqtt->subscribe('$queue/test/test/+/+/+/+/+/clientState/#', array('qos' => 0), function ($exception, $granted) {
if ($exception) {var_dump($exception);} else {var_dump('aaa', $granted);}
} );
};
$mqtt->onMessage = function ($topic, $content) use ( $mqtt ) {
$topicArr = explode('/',$topic);
$modelId = $topicArr[5] ?? 0;
$key = $topicArr[6] ?? '';
$class = null;
if ($modelId && $key){
$className = 'Device'.$modelId.'Service';
$flag = class_exists($className);
if ($flag){
$class = new $className;
}
}
if ($class){
$class->consumeMessagePrinter($topic, $content,$mqtt);
}else{
$data = (new OperationService) ->consumeMessagePrinter($topic, $content,$mqtt);
}
};
$mqtt->connect();
};
涨到一定程度了不涨了就不算内存泄露。
比如到200M就不涨了就不是。
好的 我再观察观察