简体   繁体   English

识别Javascript堆外部的内存泄漏

[英]Identifying memory leak outside of Javascript heap

I'm debugging a memory leak in a complex Javascript application (hundreds of files and nearly a million lines of code). 我正在调试复杂的Javascript应用程序中的内存泄漏(数百个文件和近百万行代码)。 It is a game, so it has heavy use of PNG graphics and the 2d canvas as well. 这是一款游戏,因此它大量使用PNG图形和2D画布。

When memory profiling with Chrome's dev tools, I don't see much change in the heap allocation, yet the memory usage in Chrome's task manager continues to rise. 使用Chrome的开发工具进行内存分析时,我看不到堆分配有太大变化,但Chrome的任务管理器中的内存使用量持续上升。 In fact, the GPU memory plus the JS memory only total about half of the total memory. 实际上,GPU内存加JS内存只占总内存的一半左右。 How can I go about debugging where the rest of this memory is going? 我怎样才能调试内存的其余部分?

In very many cases a leak in the native memory has a leaked object in js memory. 在很多情况下,本机内存中的泄漏在js内存中有泄漏的对象。 So with a very high probability after fixing all the js leaks in your app you will have no leaks in the native memory. 因此,在修复应用程序中的所有js泄漏后,非常高的概率,您将在本机内存中没有泄漏。

See the answer Tool to track down JavaScript memory leak 请参阅答案工具以跟踪JavaScript内存泄漏

The dom nodes occupy native memory directly hence higher the dom nodes higher the native memory consumption. dom节点直接占用本机内存,因此dom节点越高,本机内存消耗越高。 Also since you mentioned there are lot of graphics involved you need to take into account that an image rendered in an <img> tag takes up additional native memory and it is usually more than its original image size. 此外,由于您提到涉及许多图形,您需要考虑在<img>标记中呈现的图像占用额外的本机内存,并且通常超过其原始图像大小。

Since its been a year you asked this question if you have probably solved your issue you can write your solutions for others here. 从你问过这个问题一年后,如果你可能已经解决了你的问题,你可以在这里为别人写下你的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM