久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='J9EQC'></tfoot>

      <bdo id='J9EQC'></bdo><ul id='J9EQC'></ul>

  1. <legend id='J9EQC'><style id='J9EQC'><dir id='J9EQC'><q id='J9EQC'></q></dir></style></legend>
  2. <i id='J9EQC'><tr id='J9EQC'><dt id='J9EQC'><q id='J9EQC'><span id='J9EQC'><b id='J9EQC'><form id='J9EQC'><ins id='J9EQC'></ins><ul id='J9EQC'></ul><sub id='J9EQC'></sub></form><legend id='J9EQC'></legend><bdo id='J9EQC'><pre id='J9EQC'><center id='J9EQC'></center></pre></bdo></b><th id='J9EQC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='J9EQC'><tfoot id='J9EQC'></tfoot><dl id='J9EQC'><fieldset id='J9EQC'></fieldset></dl></div>

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

      將對象設置為 null 時的 JavaScript(ES6)WeakMap 垃圾回

      JavaScript(ES6) WeakMap garbage collection when set an object to null(將對象設置為 null 時的 JavaScript(ES6)WeakMap 垃圾回收)

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

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

          • <legend id='JPKS0'><style id='JPKS0'><dir id='JPKS0'><q id='JPKS0'></q></dir></style></legend>
            • <bdo id='JPKS0'></bdo><ul id='JPKS0'></ul>
                本文介紹了將對象設置為 null 時的 JavaScript(ES6)WeakMap 垃圾回收的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我剛剛讀到 WeakMaps 通過專門使用對象作為鍵來利用垃圾回收,并且將對象分配給 null 相當于刪除它:

                I've just read that WeakMaps take advantage of garbage collection by working exclusively with objects as keys, and that assigning an object to null is equivalent to delete it:

                let planet1 = {name: 'Coruscant', city: 'Galactic City'};
                let planet2 = {name: 'Tatooine', city: 'Mos Eisley'};
                let planet3 = {name: 'Kashyyyk', city: 'Rwookrrorro'};
                
                const lore = new WeakMap();
                lore.set(planet1, true);
                lore.set(planet2, true);
                lore.set(planet3, true);
                console.log(lore); // output: WeakMap?{{…} => true, {…} => true, {…} => true}
                

                然后我將對象設置為null:

                Then I set the object equal to null:

                planet1 = null;
                console.log(lore); // output: WeakMap?{{…} => true, {…} => true, {…} => true}
                

                為什么輸出相同?難道不應該刪除它,以便 gc 可以重用以前在應用程序中占用的內存嗎?我將不勝感激.謝謝!

                Why is the output the same? Wasn't it supposed to be deleted so that the gc could reuse the memory previously occupied later in the app? I would appreciate any clarification. Thanks!

                推薦答案

                垃圾回收沒有立即運行.如果您希望您的示例正常工作,您需要強制您的瀏覽器運行垃圾收集.

                Garbage collection does not run immediately. If you want your example to work you need to force your browser to run garbage collection.

                使用以下標志運行 chrome:google-chrome --js-flags="--expose-gc".

                Run chrome with the following flag: google-chrome --js-flags="--expose-gc".

                您現在可以通過調用全局 gc() 方法來強制進行垃圾回收.

                You can now force the garbage collection by calling the global gc() method.

                這篇關于將對象設置為 null 時的 JavaScript(ES6)WeakMap 垃圾回收的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)

                • <small id='7eU85'></small><noframes id='7eU85'>

                    <legend id='7eU85'><style id='7eU85'><dir id='7eU85'><q id='7eU85'></q></dir></style></legend>

                        <bdo id='7eU85'></bdo><ul id='7eU85'></ul>
                        <i id='7eU85'><tr id='7eU85'><dt id='7eU85'><q id='7eU85'><span id='7eU85'><b id='7eU85'><form id='7eU85'><ins id='7eU85'></ins><ul id='7eU85'></ul><sub id='7eU85'></sub></form><legend id='7eU85'></legend><bdo id='7eU85'><pre id='7eU85'><center id='7eU85'></center></pre></bdo></b><th id='7eU85'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7eU85'><tfoot id='7eU85'></tfoot><dl id='7eU85'><fieldset id='7eU85'></fieldset></dl></div>
                      • <tfoot id='7eU85'></tfoot>
                            <tbody id='7eU85'></tbody>
                          主站蜘蛛池模板: 成人特区 | 伊人影院99 | 免费h视频 | 国产精品久久久久一区二区三区 | 日韩精品久久久 | 国产在线色 | 97色伦网 | 国产高清在线精品 | 成在线人视频免费视频 | 国产精品久久片 | 午夜免费网站 | 成人欧美一区二区三区在线播放 | 日韩中文不卡 | 日韩一二三区视频 | 黄色av一区 | 精品99久久久久久 | 一区二区三区在线播放 | 免费观看国产视频在线 | 欧美日韩精品一区二区 | 99亚洲精品 | 欧美综合一区 | 国产欧美精品 | 成人精品一区二区 | 日韩欧美三区 | 日本一区二区三区四区 | 国产精品日产欧美久久久久 | 国外成人免费视频 | 欧美精品久久久久 | 久久亚洲欧美日韩精品专区 | 高清久久| 一区二区三区国产视频 | 久久久久久久国产精品视频 | 在线观看www| 少妇精品久久久久久久久久 | 成人精品 | 国产一区二区三区在线 | 91精品一区 | 婷婷久久精品一区二区 | 日韩视频在线一区 | 日本亚洲一区 | 人人看人人爽 |