From 84dc221b2e03cf92e8ce091c5ed6201e85e372b7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 4 May 2013 21:52:14 +0800 Subject: [PATCH] Clear listeners on process object when unloading. The process object is created under node context, and it will live through the reloading, so we are responsible for clearing the listeners to make sure resources are not leaked. --- renderer/api/lib/ipc.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/renderer/api/lib/ipc.coffee b/renderer/api/lib/ipc.coffee index 2ef1290d9801..28b9a9692d04 100644 --- a/renderer/api/lib/ipc.coffee +++ b/renderer/api/lib/ipc.coffee @@ -6,6 +6,9 @@ class Ipc extends EventEmitter process.on 'ATOM_INTERNAL_MESSAGE', (args...) => @emit(args...) + window.addEventListener 'unload', (event) -> + process.removeAllListeners 'ATOM_INTERNAL_MESSAGE' + send: (args...) -> ipc.send('ATOM_INTERNAL_MESSAGE', 'message', args...)