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

Open
opened 2026-01-29 16:59:34 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/ElectronNET/Electron.NET/pull/833

State: closed
Merged: Yes


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.

**Original Pull Request:** https://github.com/ElectronNET/Electron.NET/pull/833 **State:** closed **Merged:** Yes --- 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](https://github.com/ElectronNET/Electron.NET/assets/58216719/2f1dc316-1696-4a15-aaa0-6d0d7368924a) 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.
claunia added the pull-request label 2026-01-29 16:59:34 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1317