
在開發一款網頁前端動畫小遊戲時,因為有自動遊玩功能,發現掛了一晚上,就會發現記憶體飆昇到 1GB 問題。
在電腦科學中,內部記憶體泄漏指由於疏忽或錯誤造成程式未能釋放已經不再使用的內部記憶體的情況。 (微基百科)
瀏覽器採用的是引用計數,沒有被引用數據,會打出標記,週期性執行,釋放記憶體。
1.打開 chrome > F12 > More Tool > Performance Monitor
打開 chrome > F12 > 記憶體
beforeDestroy () { this.lottieAnimation.destroy('game-animation') this.lottieAnimation = null this.lottieApi = null }
記憶體掛一個晚上終於沒有在飆昇了。