[Service] Fix memory leak with worker isolation 15/243515/14
authorDongHyun Song <dh81.song@samsung.com>
Wed, 2 Sep 2020 08:16:19 +0000 (17:16 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Wed, 9 Sep 2020 08:26:36 +0000 (08:26 +0000)
1) apply worker.terminate(), instead of process.exit()
2) unload extensions to release extensions

Related chromium-efl patch:
  https://review.tizen.org/gerrit/243536

Change-Id: I575fa68d72280d542e36add0d5d7f4f27adb98bc
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
packaging/wrtjs.spec
wrt_app/common/service_manager.ts
wrt_app/common/service_runner.ts
wrt_app/common/wrt_xwalk_extension.ts

index 69093e1..842226c 100755 (executable)
@@ -2,7 +2,7 @@ Name:       wrtjs
 Summary:    Javascript based Runtime for Tizen
 # Version: {TPK_VERSION}.{INTERNAL_API_REVISION}.{WRTJS_VERSION}
 # The {INTERNAL_API_REVISION} is used to check compatibility with chromium-efl.
-Version:    1.0.1
+Version:    1.1.1
 Release:    1
 Group:      Web Framework/Web Runtime
 License:    Apache-2.0
index 80f1ec6..6703ff4 100644 (file)
@@ -28,10 +28,17 @@ export function startService(id: string, filename: string) {
 export function stopService(id: string) {
   console.log(`stopService - ${id}`);
   if (isStandalone()) {
-    if (runner) {
-      runner.stop(id);
+    if (!runner) {
+      console.log('runner instance is null in standalone mode');
+      return;
     }
-  } else {
+    runner.stop(id);
+    setTimeout(() => process.exit(), 500);
+} else {
     workers[id].postMessage('stopService');
+    setTimeout(() => {
+      workers[id].terminate();
+      delete workers[id];
+    }, 500);
   }
 }
index 7b53192..8e1c032 100644 (file)
@@ -80,7 +80,6 @@ export function stop(id: string) {
   } catch (e) {
     console.log(`exception on stop: ${e}`);
   }
-  setTimeout(() => process.exit(), 500);
 }
 
 function run() {
@@ -94,6 +93,7 @@ function run() {
     console.log(`message received : ${msg}`);
     if (msg === 'stopService') {
       stop(id);
+      XWalkExtension.cleanup();
     }
   });
 }
index ea8ad96..feffcdd 100644 (file)
@@ -214,6 +214,9 @@ export const setRuntimeMessageHandler = (handler: (type: string, data?: string,
 }
 
 export let cleanup = () => {
+  for (var name in extensions_) {
+    extensions_[name].unloadInstance();
+  }
   delete global.tizen;
   instance = undefined;
 }