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

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

📋 Pull Request Information

Original PR: https://github.com/ElectronNET/Electron.NET/pull/833
Author: @Yuvix25
Created: 2/14/2024
Status: Merged
Merged: 2/14/2024
Merged by: @FlorianRappl

Base: mainHead: ipc-once-memory


📝 Commits (1)

  • 1253df3 Fix huge memory waste in IpcMain.Once

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 src/ElectronNET.API/IpcMain.cs (+1 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ElectronNET/Electron.NET/pull/833 **Author:** [@Yuvix25](https://github.com/Yuvix25) **Created:** 2/14/2024 **Status:** ✅ Merged **Merged:** 2/14/2024 **Merged by:** [@FlorianRappl](https://github.com/FlorianRappl) **Base:** `main` ← **Head:** `ipc-once-memory` --- ### 📝 Commits (1) - [`1253df3`](https://github.com/ElectronNET/Electron.NET/commit/1253df3d9ae7d874b95f5b75089f9467fa778b35) Fix huge memory waste in IpcMain.Once ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/ElectronNET.API/IpcMain.cs` (+1 -1) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1312