From c0be4dff8cb45cf1c9e058eb7812b07a6714ce29 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 16 Sep 2021 14:02:13 +0900 Subject: [PATCH] [Service] Fix memory leak of parentPort From an againg test, which repeatedly launch/terminate an empty service app, we can find that memory size is continuously increasing. With checking service_runner.ts line by line, I figure out that parentPort (MessagePort) is related to memory leak. parentPort.close() can be effective to make memory usage stable a little. Change-Id: Ia5737915507452100e729246e8f658715d603e81 Signed-off-by: DongHyun Song --- wrt_app/service/service_runner.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/wrt_app/service/service_runner.ts b/wrt_app/service/service_runner.ts index 63766c7..e712b03 100644 --- a/wrt_app/service/service_runner.ts +++ b/wrt_app/service/service_runner.ts @@ -142,15 +142,11 @@ function run() { writable: false }); - // FIXME: this should be 'wrt.tv?.serviceMount(id)' after Tizen 6.5 release - (wrt.tv as any)?.serviceMount(id); - + wrt.tv?.serviceMount(id); let filename = workerData.filename; start(id, filename); - if (!parentPort) - return; - parentPort.on('message', (message) => { + parentPort?.on('message', (message) => { console.debug(`Received message type : ${message.type}`); if (message.type === 'wake') { app?.onRequest(); @@ -159,7 +155,8 @@ function run() { setTimeout(() => { XWalkExtension.cleanup(); parentPort?.postMessage("will-terminate"); - (wrt.tv as any)?.serviceUmount(id); + parentPort?.close(); + wrt.tv?.serviceUmount(id); }, message.delay); } }); -- 2.7.4