-
-
Notifications
You must be signed in to change notification settings - Fork 87
Memory Leak in Tests #104
Comments
Retainers:
That line number is in Test.registerWaiter(() => this.pendingRequestCount === 0); The |
Hey @jamesarosen! Thanks for reporting this. I've made a PR to remove the |
Thanks for the quick turnaround. Your proposed fix doesn't quite do it because even though |
You might be able to do it with a closure-local variable: let pendingRequestCount = 0;
export default class AjaxRequest {
// in case other clients of service:ajax need access to this variable:
get pendingRequestCount() {
return pendingRequestCount;
}
init() {
pendingRequestCount = 0;
if (testing) {
Test.registerWaiter(function() { return pendingRequestCount === 0; });
}
}
} Then the callback only has a handle on the module, which the requireJS global module system already has a handle on, so there's no new leak. But that means the pending-request count is global, not per-instance of |
I don't think that would matter (having that variable being per-instance of Also, thanks for the patience and good explanations; I've never dealt much with memory issues so this is a huge learning opportunity for me! |
Also, just to I can understand why this was an issue, from a learning-more-about-JS perspective... The issue is that Is that right? |
Exactly! Though it's not the |
Oh wow, I see. So, if it were just the ES6 class it wouldn't be (as much of) a problem, right? |
Probably not too bad, no. Still a leak, but most systems probably wouldn't notice. |
Cool. If we used |
It may. I don't know much about how |
@jamesarosen awesome, thanks. I pushed a commit that moves back to the per-instance count, and then tears down the waiter when the service is destroyed (which should be done at the end of each acceptance test). |
Now I see the leak again, though I can no longer tie it directly to this path, so I can't really say whether the |
* Fix memory leak in tests Closes #104 * Make the number of pending requests global * Avoid unnecessary fat-arrow function * Switch to one, global waiter
Thanks for working with me on this @jamesarosen! I just released |
I'm converting an Ember 1.13 app from ember-cli-ic-ajax to ember-ajax and my tests keep running out of memory. See the discussion below for the (likely) cause.
The text was updated successfully, but these errors were encountered: