mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
[PR #833] [MERGED] Fix huge memory waste in IpcMain.Once [IMPORTANT] #1312
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
main← Head:ipc-once-memory📝 Commits (1)
1253df3Fix 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.Onceto wait for an "all good, next frame" message from the front end. It's updating data at rates well over 60fps, so I'm callingIpcMain.Oncea 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: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.OninIpcMain.OncewithSocket.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.