内容简介:What are memory leaks?No matter what programming language you code in the lifecycle of memory management is pretty much the same.While this may seem pretty straightforward memory doesn’t always get released. In a simple app this is not a huge issue but in
What are memory leaks?
No matter what programming language you code in the lifecycle of memory management is pretty much the same.
While this may seem pretty straightforward memory doesn’t always get released. In a simple app this is not a huge issue but in larger applications this can pile up and lead to the codebase experiencing a serious memory leak and the application may end up not working properly. While at the beginning you might just see slow performance, in the long term if unaddressed the leak can lead to bigger issues and crashes. In short, a memory leak is data that may not be garbage collected and is not put to use.
Chrome developer tools have a handy option for taking heap snapshots but the information is hard to decipher.
While we loved the v8 engine data we felt that there was a visual aspect that was missing. You could only view it from the Chrome dev tools memory tab. We used node-heapdump to get the information out of the browser and into our app. We also used WebSockets to send and receive data in real-time through a duplex stream between aether’s server and the client it’s installed on. WebSockets allow for a higher amount of efficiency compared to REST because they do not require the HTTP request/response overhead for each message sent and received.
The heap snapshot data that was coming back was initially overwhelming to look at and hard to make sense of. So in order to help us write better code and debug our codebases we parsed through the snapshots and developed a tool that would help us see at a glance the size of nodes and overall memory usage.
This chart shows the self size of the nodes in an application.
Self size — The size of the memory contained by the node itself. Very large objects will have large self sizes, like long strings, dictionaries, and functions with large bodies.
Retained size — The object’s self size plus the sizes of all of the objects that would be freed should the object be deleted.
This chart shows an example of spikes in memory usage in your application.
If you’re interested in trying it for yourself here is a link to the tool! https://github.com/oslabs-beta/aether/
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
跨平台桌面应用开发:基于Electron与NW.js
【丹】Paul B. Jensen / Goddy Zhao / 2018-3 / 99
《跨平台桌面应用开发:基于Electron与NW.js》是一本同时介绍 Electron和 NW.js的图书,这两者是目前流行的支持使用 HTML、CSS 和 JavaScript 进行桌面应用开发的框架。书中包含大量的编码示例,而且每个示例都是五脏俱全的实用应用,作者对示例中的关键代码都做了非常详细的解释和说明,可让读者通过实际的编码体会使用这两款框架开发桌面应用的切实感受。除此之外,在内容上,......一起来看看 《跨平台桌面应用开发:基于Electron与NW.js》 这本书的介绍吧!