<tfoot id='UIDQx'></tfoot>

      <i id='UIDQx'><tr id='UIDQx'><dt id='UIDQx'><q id='UIDQx'><span id='UIDQx'><b id='UIDQx'><form id='UIDQx'><ins id='UIDQx'></ins><ul id='UIDQx'></ul><sub id='UIDQx'></sub></form><legend id='UIDQx'></legend><bdo id='UIDQx'><pre id='UIDQx'><center id='UIDQx'></center></pre></bdo></b><th id='UIDQx'></th></span></q></dt></tr></i><div id='UIDQx'><tfoot id='UIDQx'></tfoot><dl id='UIDQx'><fieldset id='UIDQx'></fieldset></dl></div>

    1. <small id='UIDQx'></small><noframes id='UIDQx'>

        <bdo id='UIDQx'></bdo><ul id='UIDQx'></ul>
        <legend id='UIDQx'><style id='UIDQx'><dir id='UIDQx'><q id='UIDQx'></q></dir></style></legend>

        JavaScript 内存管理的陷阱?

        时间:2023-10-12
        • <bdo id='9g89o'></bdo><ul id='9g89o'></ul>

          <small id='9g89o'></small><noframes id='9g89o'>

                <i id='9g89o'><tr id='9g89o'><dt id='9g89o'><q id='9g89o'><span id='9g89o'><b id='9g89o'><form id='9g89o'><ins id='9g89o'></ins><ul id='9g89o'></ul><sub id='9g89o'></sub></form><legend id='9g89o'></legend><bdo id='9g89o'><pre id='9g89o'><center id='9g89o'></center></pre></bdo></b><th id='9g89o'></th></span></q></dt></tr></i><div id='9g89o'><tfoot id='9g89o'></tfoot><dl id='9g89o'><fieldset id='9g89o'></fieldset></dl></div>
                <legend id='9g89o'><style id='9g89o'><dir id='9g89o'><q id='9g89o'></q></dir></style></legend>
                  <tbody id='9g89o'></tbody>
                • <tfoot id='9g89o'></tfoot>

                  本文介绍了JavaScript 内存管理的陷阱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我知道 JavaScript 有一个垃圾收集器.因此,使用delete只删除一个对该对象的引用,当没有对该对象的引用时,它被GC删除.

                  I know that JavaScript has a garbage collector. Therefore, using delete remove only a reference to the object, and when there is no more reference to this object, it is deleted by the GC.

                  JavaScript 很棘手,由于闭包、模糊的命名空间和原型继承,知道什么时候到现在或为什么并不总是很明显.

                  JavaScript is tricky, with the closures, the fuzzy name space and the prototype inheritance, it's not always obvious to know when to now or why.

                  我正在编写一个相当大的 JavaScript 项目,并希望避免内存泄漏,同时限制全局内存使用.我根本不在优化阶段(让我们先让这些东西工作:-)),但如果知道内存管理的良好做法以避免编写糟糕的代码,那就太好了.

                  I am coding a fairly large JavaScript project and would like to avoid memory leak, while limiting the global memory usage. I am not at all in the optimizing stage (let's get the stuff work first :-)), but it would be nice to know the good practices for memory management in order to avoid writing crappy code.

                  • 那么我应该什么时候使用delete?
                  • 我应该避免哪些陷阱,使用对象?
                  • 关于闭包的一些知识?
                  • 要强调一些好的做法?

                  推荐答案

                  根据我的经验,垃圾收集器的实现好/不好取决于浏览器.应用良好的面向对象编程实践是一个好的开始.

                  From my experience, Garbage Collectors are well/poorly implemented depending on the browser. Applying good Object Oriented programming practices is a good start.

                  我唯一的建议:不要通过连接 DOM 和javascript 对象(不会被 DOM 和 JS GC 清除的循环引用).这些错误会比您在应用程序中实例化的任何对象消耗更多的内存.

                  My only advice: do not create memory leaks by connecting DOM & javascript objects (circular references that won't be cleared by DOM and JS GCs). These mistakes will eat far more memory than any object you will instantiate within your application.

                  有关 DOM/JS 内存泄漏的更多详细信息.http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx

                  More details on DOM/JS memory leaks. http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx

                  这篇关于JavaScript 内存管理的陷阱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将对象的所有键转换为小写的最佳方法(最有效 下一篇:Javascript中同一变量上的“new"没有“delete&qu

                  相关文章

                  最新文章

                    <i id='inpKN'><tr id='inpKN'><dt id='inpKN'><q id='inpKN'><span id='inpKN'><b id='inpKN'><form id='inpKN'><ins id='inpKN'></ins><ul id='inpKN'></ul><sub id='inpKN'></sub></form><legend id='inpKN'></legend><bdo id='inpKN'><pre id='inpKN'><center id='inpKN'></center></pre></bdo></b><th id='inpKN'></th></span></q></dt></tr></i><div id='inpKN'><tfoot id='inpKN'></tfoot><dl id='inpKN'><fieldset id='inpKN'></fieldset></dl></div>

                    <small id='inpKN'></small><noframes id='inpKN'>

                  1. <tfoot id='inpKN'></tfoot>

                      <legend id='inpKN'><style id='inpKN'><dir id='inpKN'><q id='inpKN'></q></dir></style></legend>
                        <bdo id='inpKN'></bdo><ul id='inpKN'></ul>