Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : CanJS Memory Leak!

$
0
0
So some additional testing has uncovered some issues with this fix.

As I navigate about my app, I ran into a "maximum call stack exceeded" error. 

This occurs when I switch between different views of the same groups of models.

My models do not contain any cycles where a model contains another model that contains it. Although I'd argue that should be allowed. But I do have something like this going on. A Player model can have a list of Team models and a Team model can have a list of Player models, but I make sure that they do contain cycles. 

When I use master, this error does not occur.

I seem to have pinpointed the culprit in my code. In one of my controls I create a can.compute that wraps around some model attributes. I set that compute to one of the control's options and then rebind the controls bindings with this.on() and have a templated event on the control listening to changes on that option  ( I have another post about this pattern ).

If I don't do this, this "maximum call stack" error does not happen. It works fine in master.

Justin, the suggested change in bind.js did not fix the problem. Well it did, sorta, but instead of getting the maximum call stack error, I get a different error. It doesn't actually show an error, but it just keeps logging "removing...." from _bindteardown and the page soon turns all white (blank) and the console becomes unusable. So it seems like an infinite loop in a different place.

If I call myModel.store = { } in the destroy of the control using myModels, this problem goes away. But I know this is not a good thing to do, nor the solution. But perhaps it is a hint to help find the real solution. 

Why does clearing out the store make the problem go away? If a model is in the store, does that always mean that something is binding to it?

Thoughts? Definitely hoping to get this figured out.


Viewing all articles
Browse latest Browse all 3491

Trending Articles