Browse Source

Merge pull request #201 from UnsungHero97/master

fix for memory leak in dataconnection.js
Michelle Bu 11 years ago
parent
commit
0b0c554df4
1 changed files with 4 additions and 3 deletions
  1. 4 3
      lib/dataconnection.js

+ 4 - 3
lib/dataconnection.js

@@ -118,12 +118,13 @@ DataConnection.prototype._handleDataMessage = function(e) {
     chunkInfo.count += 1;
 
     if (chunkInfo.total === chunkInfo.count) {
+      
+      // free up memory before making the recursive call to _handleDataMessage()
+      delete this._chunkedData[id];
+      
       // We've received all the chunks--time to construct the complete data.
       data = new Blob(chunkInfo.data);
       this._handleDataMessage({data: data});
-
-      // We can also just delete the chunks now.
-      delete this._chunkedData[id];
     }
 
     this._chunkedData[id] = chunkInfo;