From 1200ced4497d401aea6ef3f24740ee98d4ba8a9f Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 9 Sep 2021 10:26:53 +0200 Subject: [PATCH] fix(realtime): memory leak with swoole table --- app/realtime.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index 9112810e7..40537ea61 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -110,8 +110,8 @@ $server->onStart(function () use ($stats, $register, $containerId, &$documentId) continue; } - $connections = $value['connections']; - $messages = $value['messages']; + $connections = $stats->get($projectId, 'connections'); + $messages = $stats->get($projectId, 'messages'); $usage = new Event('v1-usage', 'UsageV1'); $usage @@ -129,11 +129,13 @@ $server->onStart(function () use ($stats, $register, $containerId, &$documentId) if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $usage->trigger(); } + + unset($usage, $connections, $messages); } $payload = []; foreach ($stats as $projectId => $value) { if (!empty($value['connectionsTotal'])) { - $payload[$projectId] = $value['connectionsTotal']; + $payload[$projectId] = $stats->get($projectId, 'connectionsTotal'); } } if (empty($payload)) { @@ -210,7 +212,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, $event = [ 'project' => 'console', - 'roles' => ['team:' . $value['teamId']], + 'roles' => ['team:' . $stats->get($projectId, 'teamId')], 'data' => [ 'event' => 'stats.connections', 'channels' => ['project'],