Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core - Memory leak audit #7

Open
Trylobot opened this issue Jun 12, 2014 · 0 comments
Open

Core - Memory leak audit #7

Trylobot opened this issue Jun 12, 2014 · 0 comments

Comments

@Trylobot
Copy link
Owner

I suspect closures are being created as a side effect of my {Module}.create(...) pattern, because in at least one place the object returned is referencing variables created in the scope of the object creation function; if the object is deleted, the scope probably will not be destroyed because it actually belongs to the module itself, and so will probably remain in memory.

// DO this
function create() {
  return new (function ModuleObject() {
    var self = this;
    self.x = 5;
    self.add = function() {
      self.x++;
    }
  })();
}

// DON'T do this
function create() {
  var x = 5;
  var module_object = {
    x: x
  }
  module_object.add = function() {
    module_object.x++;
  }
  return module_object;
}
@Trylobot Trylobot added the bug label Jun 12, 2014
@Trylobot Trylobot self-assigned this Jun 12, 2014
@Trylobot Trylobot removed their assignment Jun 20, 2014
@Trylobot Trylobot changed the title Memory leak audit 1 Core - Memory leak audit Jun 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant