问题描述
我正在开发一个带有很多Javascript的AJAX应用程序。所有页面都通过AJAX加载。
在某个页面上,我有一个以Javascript构建的网格。现在,当我离开那个页面时,我想摧毁那个网格。我调用jQuery.remove(),但这只会从DOM删除对象。
我的问题是如何从内存中删除这个网格对象?因为它仍然存在,当我离开页面。
非常感谢!
I am working on an AJAX application with a lot of Javascript. All pages are loaded through AJAX.
On a certain page I have a grid which is build in Javascript. Now when I leave that page I want to destroy that grid. I call jQuery.remove() but this only deletes the object from the DOM.
My question is how can I delete this grid object from the memory? Cause it still exists when I move away from the page.
Much appreciated!
If you delete all references to your grid (i.e. assign null to the variable), the garbage collector will delete the object from memory.
这篇关于在javascript中从内存中删除对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!