Clean up tern web workers whenever we re-init the tern server, or close a project.

If we don't call terminate on the worker, it appears that the worker, and all the memory it's using will never get collected.  So when we were switching projects, we were leaving behind orphaned workers, resulting in a large memory leak.

To enable re-initing the web worker I had to change around the logic - now the worker sends a message when it is done being init'ed and the main thread waits for that message before it starts sending messages to the workers.
This commit is contained in:
Erik Tierney committed 2013-05-23 21:10:57 -04:00
1 parent 1339fc9cd3
commit f6fdc43434
4 files changed
+402 -375

No files matched your search

@@ -35,7 +35,8 @@ define(function (require, exports, module) {
TERN_GET_FILE_MSG = "GetFile",
TERN_CALLED_FUNC_TYPE_MSG = "FunctionType",
TERN_PRIME_PUMP_MSG = "PrimePump",
TERN_GET_GUESSES_MSG = "GetGuesses";
TERN_GET_GUESSES_MSG = "GetGuesses",
TERN_WORKER_READY = "WorkerReady";
exports.TERN_ADD_FILES_MSG = TERN_ADD_FILES_MSG;
exports.TERN_JUMPTODEF_MSG = TERN_JUMPTODEF_MSG;