From 764fa3e34aca8e8c69db05665987681a8495795d Mon Sep 17 00:00:00 2001 From: Henri Astre Date: Tue, 17 Jun 2014 17:26:10 -0700 Subject: [PATCH 1/3] Fix memory leak while destroying the viewer. --- src/drawer.js | 17 ++++++++- src/mousetracker.js | 3 ++ src/viewer.js | 9 ++++- test/demo/memory_check.html | 71 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 test/demo/memory_check.html diff --git a/src/drawer.js b/src/drawer.js index 54b07281..95da18ce 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -302,7 +302,22 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{ */ canRotate: function() { return this.useCanvas; - } + }, + + /** + * Destroy the drawer (unload current loaded tiles) + */ + destroy: function() { + + //unload current loaded tiles (=empty TILE_CACHE) + for (var i=0; i + + + OpenSeadragon Memory Check Demo + + + + +
+ Simple demo page to monitor OpenSeadragon Memory Usage. +
+ + + +
+ + + \ No newline at end of file From a563bdb65805730358eee5c7194ff4a9b46388eb Mon Sep 17 00:00:00 2001 From: Henri Astre Date: Wed, 18 Jun 2014 10:35:23 -0700 Subject: [PATCH 2/3] fix .close() called after .destroy() + spacing --- src/drawer.js | 31 ++++++++-------- src/mousetracker.js | 6 ++-- src/viewer.js | 26 +++++++++----- test/basic.js | 1 + test/demo/memory_check.html | 71 ------------------------------------- test/demo/memorycheck.html | 57 +++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 97 deletions(-) delete mode 100644 test/demo/memory_check.html create mode 100644 test/demo/memorycheck.html diff --git a/src/drawer.js b/src/drawer.js index 95da18ce..10165ffb 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -303,21 +303,22 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{ canRotate: function() { return this.useCanvas; }, - - /** - * Destroy the drawer (unload current loaded tiles) - */ - destroy: function() { - - //unload current loaded tiles (=empty TILE_CACHE) - for (var i=0; i - - - OpenSeadragon Memory Check Demo - - - - -
- Simple demo page to monitor OpenSeadragon Memory Usage. -
- - - -
- - - \ No newline at end of file diff --git a/test/demo/memorycheck.html b/test/demo/memorycheck.html new file mode 100644 index 00000000..bebe80da --- /dev/null +++ b/test/demo/memorycheck.html @@ -0,0 +1,57 @@ + + + + OpenSeadragon Memory Check Demo + + + + +
+ Simple demo page to monitor OpenSeadragon Memory Usage. +
+ + + +
+ + + From f86f9063fd32a4164169cb8ec4c7ab61a02f69fb Mon Sep 17 00:00:00 2001 From: Henri Astre Date: Wed, 18 Jun 2014 12:56:36 -0700 Subject: [PATCH 3/3] Improve comment for destroy() method. --- src/viewer.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/viewer.js b/src/viewer.js index cb8e295f..7ba1e7c0 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -578,8 +578,17 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, /** - * Function to destroy the viewer and clean up everything created by - * OpenSeadragon. + * Function to destroy the viewer and clean up everything created by OpenSeadragon. + * + * Example: + * var viewer = OpenSeadragon({ + * [...] + * }); + * + * //when you are done with the viewer: + * viewer.destroy(); + * viewer = null; //important + * * @function */ destroy: function( ) {