Permalink
Browse files

fix Spark memory leak (#1157)

  • Loading branch information...
dgreensp committed Jun 25, 2013
1 parent 972e295 commit 49e98134fda0f81948cb71b6081ac4c417713f99
Showing with 15 additions and 0 deletions.
  1. +15 −0 packages/spark/spark.js
View
@@ -1205,6 +1205,21 @@ Spark.createLandmark = function (options, htmlFunc) {
landmark._range = range;
renderer.landmarkRanges.push(range);
// Help GC avoid an actual memory leak (#1157) by nulling the
// `renderer` local variable, which holds data structures about
// the preservation and patching performed during this rendering
// pass, including references to the old LiveRanges. If
// `renderer` is retained by the LiveRange we initialize here,
// it creates a chain linking the new LiveRanges to the
// renderer, to the old LiveRanges, to the old renderer, etc.
//
// The reason the new LiveRange might retains `renderer` has to
// do with how V8 implements closures. V8 considers
// `range.finalize` to close over `renderer`, even though it
// doesn't use it. Because `renderer` is used by *some* nested
// closure, it apparently is retained by all nested closures as
// part of `Spark.createLandmark`'s function context.
renderer = null;
});
};

5 comments on commit 49e9813

@frozeman

This comment has been minimized.

Show comment
Hide comment

👍

@pablo-guevara-zocdoc

This comment has been minimized.

Show comment
Hide comment
@crapthings

This comment has been minimized.

Show comment
Hide comment
@crapthings

crapthings Jul 1, 2013

can't wait lalala

can't wait lalala

@evandrix

This comment has been minimized.

Show comment
Hide comment
Please sign in to comment.