在下图测试代码第13行和第16行设断点. 以调试方式运行,首先断点在第13行处触发:
![683](https://i-blog.csdnimg.cn/blog_migrate/3c0dedaddb54f58b7be34658c2dd7537.webp?x-image-process=image/format,png)
打开Chrome开发者工具,点击Profiles tab, 再点击按钮"Take Snapshot":
![700](https://i-blog.csdnimg.cn/blog_migrate/0d8589720e9f78e7706934e9eb3463f4.webp?x-image-process=image/format,png)
生成一个Snapshot, ID为3:
![700](https://i-blog.csdnimg.cn/blog_migrate/f7ad4e54f9f79fc560b9ee81ca0bc158.webp?x-image-process=image/format,png)
继续以调试mode执行代码到第16行,点击按钮"Take heap snapshot"以生成第二个snapshot。从下拉菜单里选择"Objects allocated between Snapshot 3 and Snapshot 4":
![700](https://i-blog.csdnimg.cn/blog_migrate/147d3fd926053ffceaa6fa459db5cb48.webp?x-image-process=image/format,png)
在下图Summary里用变量名"arra"做filter,即可找出在snapshot3和snapshot4之间内存占用最高的变量arra:
![700](https://i-blog.csdnimg.cn/blog_migrate/f403cd640ebb80049561fe96a66913c8.webp?x-image-process=image/format,png)
将鼠标停留在arra上即可查看这个变量包含的内容:
![425](https://i-blog.csdnimg.cn/blog_migrate/3cdfa4bc73d09c7a91b9627db662d028.webp?x-image-process=image/format,png)
![358](https://i-blog.csdnimg.cn/blog_migrate/0159cb68de3f44b52f6d965fa82daf80.webp?x-image-process=image/format,png)
要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:
![283](https://i-blog.csdnimg.cn/blog_migrate/5f6c3279490b304b450912f0c96e75dc.webp?x-image-process=image/format,png)
![700](https://i-blog.csdnimg.cn/blog_migrate/71b0826280274caf4ff0084561ea8c7a.webp?x-image-process=image/format,png)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24475491/viewspace-2151616/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24475491/viewspace-2151616/