Skip to content

Fix huge memory waste in IpcMain.Once [IMPORTANT] #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

Yuvix25
Copy link
Contributor

@Yuvix25 Yuvix25 commented Feb 14, 2024

My app uses IpcMain.Once to wait for an "all good, next frame" message from the front end. It's updating data at rates well over 60fps, so I'm calling IpcMain.Once a lot. I noticed that since I started doing this, my memory usage went waaay up (from 40-50Mb to about 800Mb), so I started investigating memory dumps, and indeed, I found this object:
image
Which I later traced to be the object holding all of the socket listeners.

To fix this issue, all I had to do was replace the Socket.On in IpcMain.Once with Socket.Once<object>, and my memory usage went back down to 40-50Mb.

Copy link
Collaborator

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@FlorianRappl FlorianRappl merged commit 0d63383 into ElectronNET:main Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants