电子内存使用分析 [英] electron memory usage profiling

查看:12
本文介绍了电子内存使用分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电子应用程序存在一些内存问题.启动时内存使用量约为 120 MB.JS 堆保持在 32 MB 不变.在浏览器窗口中不执行任何操作时,任务管理器中渲染器的内存使用量每秒增加约 1 MB.在增加 20 MB 后,它似乎又下降了 16 左右(可能是 GC).但是让窗口打开几分钟会导致 300 MB 内存使用.所以某处存在内存泄漏.

I have some memory problems with my electron app. On startup the memory usage is about 120 MB. The JS heap stays constant at 32 MB. Without performing any actions in the browser window, the memory usage of the renderer in the task manager goes up by about 1 MB every second. After increasing by 20 MB it seems to go down by around 16 again (propably GC). but leaving the window open for several minutes results in 300 MB memory usage. So there is a memory leak somewhere.

由于 JS 堆大小永远不会改变,我假设 Node 进程内部存在泄漏,我在这方面是否正确?如何分析电子/节点进程中的内存使用情况?(因为 chrome 配置文件在这种情况下似乎没有帮助)

Since the JS heap size never changes, I assume the leak in inside the Node process, am I correct on that part? How can I analyze the memory usage in the electron/node process? (since the chrome profile does not seem to help in that case)

https://spectrum.chat/electron/general/debugging-high-memory-usage-in-electron~80057ff2-a51c-427f-b6e1-c297d47baf5bhttps://www.electronjs.org/docs/tutorial/performance

推荐答案

我有同样的问题,我的应用程序启动时使用了 200MB 的内存,不到 20 分钟,它使用了超过 450MB 什么都不做...只显示一些图像.树莓派 +3b 也发生了同样的情况.内存使用量不断增长,直到 rasp 死亡.

I have the same problem, my app starts with 200MB of used memory and less than 20 minutes, it uses more than 450MB just doing nothing...only showing some images. It happened the same with a raspberry pi +3b. The use of memory grows 'till rasp dies.

我发现,如果你打开了 devtools 窗口(我假设你是出于调试目的),它只会吃掉所有内存.关闭 devtools 窗口后,我在 Win 系统上的应用程序使用 100MB(稳定),在我的树莓派中使用 300MB(稳定).

What i found is that if you have the devtools window opened (i assume you have for debug purposes) it just eat all memory. Once i closed the devtools window, my app on a Win system uses 100MB (stable) and in my raspberry pi 300MB (stable).

我在某处读到,当使用 GPU 进行渲染时,它也会使用大量内存,所以我使用了

I've read somewhere that when use GPU to render it uses a lot of memory too so i used

app.disableHardwareAcceleration();

app.disableHardwareAcceleration();

这篇关于电子内存使用分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆