开发者

jquery unable to stop browser memory from raising even with unbind() and remove()

开发者 https://www.devze.com 2023-04-01 03:29 出处:网络
I\'m working on a quite complex JS application, built on jQuery + Prototype + a tiny framework of mine. The contents are completely managed thorugh AJAX calls, only the very first page being generated

I'm working on a quite complex JS application, built on jQuery + Prototype + a tiny framework of mine. The contents are completely managed thorugh AJAX calls, only the very first page being generated server side. I've read various posts about memory leaks issues (specific for jQuery and in general for JS), like Js objects/DOM cyclic references, etc. I have many kinds of events bound to elements, and managed in various ways, so I'm very exposed to memory problems. After having tried to fight all of them, now I hang on the very least MB of memeory rasing whenever I reload some content after having (I suppose) destroyed the old one. The content is made by hundreds of elements, and I've simply tried to do something like this:

var allchilds = this.mainContent.find('*');
for (var i=0;i<allchilds.length;i++){
   $j(allchilds[i]).unbind();
   $j(allchilds[i]).remove();
}
this.mainContent.remove();

It's redundant and unefficient, but I thought that this would guarantee to remove and free all the elements... but when I do it the开发者_运维百科 memory doesn't decrease, and when the new content gets loaded and rendered it raises. I know the previous snippet is a bit naive to manage memeory leaks, but could you help to find a brute force way to make FF garbage collector reclame memory?

thx, giovanni

0

精彩评论

暂无评论...
验证码 换一张
取 消