Skip to content

Callback induced memory leakage in Image caching #61

@roosmaa

Description

@roosmaa

When using the ImageView.doOnLoad, the closure is leaked due to Callback not clearing the closures on it's "to run when fired list" after being fired.

diff --git a/packages/lib/Callback.js b/packages/lib/Callback.js
index 7a610c9..b476f20 100644
--- a/packages/lib/Callback.js
+++ b/packages/lib/Callback.js
@@ -67,6 +67,8 @@ exports = Class(function() {
                for(var i = 0, len = cbs.length; i < len; ++i) {
                        if (cbs[i]) { cbs[i].apply(this, arguments); }
                }
+               // Clear listeners to prevent leakage:
+               cbs.length = 0;
        };

        this.chain = function(id) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions