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

  • <tfoot id='moj7R'></tfoot>

    1. <legend id='moj7R'><style id='moj7R'><dir id='moj7R'><q id='moj7R'></q></dir></style></legend>
      • <bdo id='moj7R'></bdo><ul id='moj7R'></ul>
    2. <small id='moj7R'></small><noframes id='moj7R'>

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

        Javascript 和垃圾收集

        Javascript and Garbage collection(Javascript 和垃圾收集)

        • <bdo id='4K02g'></bdo><ul id='4K02g'></ul>
          <tfoot id='4K02g'></tfoot>

                  <tbody id='4K02g'></tbody>

              • <legend id='4K02g'><style id='4K02g'><dir id='4K02g'><q id='4K02g'></q></dir></style></legend>

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

                  <small id='4K02g'></small><noframes id='4K02g'>

                  本文介紹了Javascript 和垃圾收集的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  有什么方法可以控制 Javascript 何時(shí)執(zhí)行垃圾回收?我想讓它在特定時(shí)間執(zhí)行垃圾收集,以確保我的網(wǎng)站順利運(yùn)行

                  Is there any way to control when Javascript performs garbage collection? I would like to enable it to perform garbage collection at certain times to ensure the smooth operation of my web site

                  推薦答案

                  Javascript 沒(méi)有顯式的內(nèi)存管理,它是瀏覽器決定何時(shí)清理它.有時(shí),由于垃圾收集暫停,您可能會(huì)遇到 JavaScript 渲染不流暢的情況.

                  Javascript doesn't have explicit memory management, it's the browser which decides when to clean it up. Sometimes it may happen that you experience un-smooth rendering of JavaScript due to a garbage collection pause.

                  您可以應(yīng)用許多技術(shù)來(lái)克服由垃圾回收 (GC) 引起的故障.應(yīng)用越多,探索越多.假設(shè)你有一個(gè)用 JavaScript 編寫(xiě)的游戲,并且每一秒你都在創(chuàng)建一個(gè)新對(duì)象,那么很明顯,在一定時(shí)間后,GC 會(huì)發(fā)生,為你的應(yīng)用程序騰出更多空間.

                  There are many techniques that you can apply to overcome glitches caused by garbage collection (GC). More you apply more you explore. Suppose you have a game written in JavaScript , and every second you are creating a new object then its obvious that at after certain amount of time GC will occur to make further space for your application.

                  對(duì)于像游戲這樣需要大量空間的實(shí)時(shí)應(yīng)用程序,您可以做的最簡(jiǎn)單的事情就是重復(fù)使用相同的內(nèi)存.這取決于您如何構(gòu)建代碼.如果它產(chǎn)生大量垃圾,那么它可能會(huì)帶來(lái)不穩(wěn)定的體驗(yàn).

                  For real time application like games, which requires lot of space the simplest thing you can do is to reuse the same memory. It depends on you how you structure your code. If it generates lots of garbage then it might give choppy experience.

                  通過(guò)簡(jiǎn)單的程序: 眾所周知,new 關(guān)鍵字表示分配.只要有可能,您可以嘗試通過(guò)添加或修改屬性每次重用相同的對(duì)象.這也稱(chēng)為對(duì)象回收

                  By using simple procedures: This is well know that new keyword indicates allocation. Wherever possible you can try to reuse the same object by each time by adding or modifying properties. This is also called recycling of object

                  在數(shù)組的情況下,分配 [] 通常用于清除數(shù)組,但您應(yīng)該記住,它也會(huì)創(chuàng)建一個(gè)新數(shù)組并丟棄舊數(shù)組.要重用相同的塊,您應(yīng)該使用 arr.length = 0 這具有相同的效果,但它重用了相同的數(shù)組對(duì)象而不是創(chuàng)建新的對(duì)象.

                  In case of Arrays, assigning [] is often used to clear array, but you should keep in mind that it also creates a new array and garbages the old one. To reuse the same block you should use arr.length = 0 This has the same effect but it reuses the same array object instead of creating new one.

                  在函數(shù)的情況下:有時(shí)我們的程序需要通過(guò)使用 setInterval 或 setTimeout 來(lái)調(diào)用特定函數(shù)更多時(shí)間或在特定時(shí)間間隔內(nèi).

                  In case of functions: Sometimes our program needed to call a specific function more time or on certain intervals by using setInterval or setTimeout.

                  ex: setTimeout(function() { doSomething() }, 10);
                  

                  您可以通過(guò)將函數(shù)分配給永久變量而不是每次定期生成來(lái)優(yōu)化上述代碼.

                  You can optimize the above code by assigning the function to a permanent variable rather than spawning each time at regular intervals.

                      ex : var myfunc = function() { doSomething() }
                      setTimeout(myfunc, 10);
                  

                  其他可能的事情是,數(shù)組 slice() 方法返回一個(gè)新數(shù)組(基于原始數(shù)組中的范圍,可以保持不變),字符串的 substr 也返回一個(gè)新字符串(基于原始字符串,可以保持不變),等等.如果沒(méi)有正確地重用,調(diào)用這些函數(shù)會(huì)產(chǎn)生垃圾.

                  Other possible thing is that, the array slice() method returns a new array (based on a range in the original array,that can remain untouched), string's substr also returns a new string (based on a range of characters in the original string, that can remain untouched), and so on. Calling these functions creates garbage if not reutilized properly.

                  在 JavaScript 中完全避免垃圾是非常困難的,你可以說(shuō)不可能.這取決于您如何重用對(duì)象和變量以避免垃圾.如果您的代碼結(jié)構(gòu)良好且經(jīng)過(guò)優(yōu)化,您可以最大限度地減少開(kāi)銷(xiāo).

                  To avoid garbage completely in JavaScript is very difficult, you could say impossible. Its depends, how you reuse the objects and variables to avoid garbage. If your code is well structured and optimized you can minimize the overhead.

                  這篇關(guān)于Javascript 和垃圾收集的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  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 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                  <i id='rFDFJ'><tr id='rFDFJ'><dt id='rFDFJ'><q id='rFDFJ'><span id='rFDFJ'><b id='rFDFJ'><form id='rFDFJ'><ins id='rFDFJ'></ins><ul id='rFDFJ'></ul><sub id='rFDFJ'></sub></form><legend id='rFDFJ'></legend><bdo id='rFDFJ'><pre id='rFDFJ'><center id='rFDFJ'></center></pre></bdo></b><th id='rFDFJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rFDFJ'><tfoot id='rFDFJ'></tfoot><dl id='rFDFJ'><fieldset id='rFDFJ'></fieldset></dl></div>

                  • <legend id='rFDFJ'><style id='rFDFJ'><dir id='rFDFJ'><q id='rFDFJ'></q></dir></style></legend>

                      <tfoot id='rFDFJ'></tfoot>
                        <bdo id='rFDFJ'></bdo><ul id='rFDFJ'></ul>

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

                            <tbody id='rFDFJ'></tbody>

                          • 主站蜘蛛池模板: 国产精品久久久久9999鸭 | 久久精品视频免费看 | 激情综合五月 | 午夜精品福利视频 | av网站免费| 欧美成视频在线观看 | 网色| 欧美成视频 | 久久99蜜桃综合影院免费观看 | 欧美国产一区二区 | 亚洲成av| 国产精品一区一区三区 | 神马久久av | 国产91 在线播放 | 99精品欧美一区二区蜜桃免费 | 精品国产一区二区在线 | 波多野结衣中文字幕一区二区三区 | 亚洲人成一区二区三区性色 | 精品国产99| 日本久久一区二区三区 | 日韩欧美三级 | 亚洲最大成人综合 | 国产一区二区久久 | 中文字幕高清免费日韩视频在线 | 欧美亚州 | 成人av观看| 一区二区三区免费观看 | www.天天操.com | 日韩欧美不卡 | 亚洲日韩中文字幕一区 | 欧美91| 国产精品久久精品 | 日本久久一区二区三区 | 欧美黄色一级毛片 | 美女久久久久久久 | 国产精品久久久久久久久久久免费看 | 亚洲草草视频 | 久久国产区 | 人和拘一级毛片c | 夜夜爽99久久国产综合精品女不卡 | 久久在线视频 |