zoukankan      html  css  js  c++  java
  • 内存泄漏 导致的后果

    会导致页面卡顿,页面崩溃

    5,6 秒以后,就能体会到内存泄漏的结果

    <style>
    #top{
         100px;
        height: 100px;
        background: red;
    }</style>
    <body>
        <div id="top"></div>
    </body>
    <script>
        var t = null;
    var replaceThing = function() {
      var o = t
      var unused = function() {
        if (o) {
          console.log("hi")
        }        
      }
      
      t = {
            longStr: new Array(100000).fill('*'),
            someMethod: function() {
                           console.log(1)
                        }
          }
    }
    setInterval(replaceThing, 10);
    
    var dom = document.getElementById('top');
    var isBlue = true;
    dom.addEventListener('click', function (params) {
        dom.style.background = isBlue?'blue':'red';
        isBlue = !isBlue;
    });
  • 相关阅读:
    设计模式——策略模式
    LeetCode
    平凡世界里的万千思绪
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/chenyi4/p/13718210.html
Copyright © 2011-2022 走看看