This calls global.gc() when a service app is terminated.
Approximately, 1 MB memory is saved by this.
Also, the main thread is immediately terminated
when there's no running worker thread for service app.
Together with:
https://review.tizen.org/gerrit/243858
Change-Id: Iab70e9aadedb19295a3784fb5cc3dc1300412995
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
if (isMainThread) {
let startService = __dirname + '/service_runner.js';
workers[id] = new Worker(startService, { workerData: { id: id, filename: filename } });
+ workers[id].on('exit', () => {
+ try {
+ global.gc();
+ console.log(`global.gc() is called by ${id}`);
+ } catch (e) {
+ console.log(`${e.name}: ${e.message}`);
+ }
+ });
}
}
}
}
runner.stop(id);
setTimeout(() => process.exit(), 500);
-} else {
+ } else {
workers[id].postMessage('stopService');
setTimeout(() => {
workers[id].terminate();
delete workers[id];
+ let runningServices = Object.keys(workers).length;
+ console.log('Running services : ' + runningServices);
+ if (runningServices === 0 && serviceType !== 'UI') {
+ process.exit();
+ }
}, 500);
}
}