mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Memory leak issue when frequently operating img in Electron.NET.(23.6.1) #853
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?
Originally created by @xiaoxinxing12 on GitHub (Mar 28, 2023).
Originally assigned to: @GregorBiswanger on GitHub.
When I use the main thread to capture images through the camera, convert them into base64 strings, send them to the rendering process through IPC, and then display them through img or canvas, it causes the memory of Electron.NET to keep increasing, and eventually it crashes. Are there any other optimization methods for displaying images captured by the main thread in HTML?
2、img
@GregorBiswanger commented on GitHub (Mar 28, 2023):
How do you load the data from the camera? Via a .NET API? Or via Nodejs?
What is your technology in .NET? ASP.NET Core or Blazor?
@GregorBiswanger commented on GitHub (Mar 28, 2023):
So I've now built a sample application using Blazor Server-Side and Electron.NET. Here I have implemented two different solutions:
https://github.com/GregorBiswanger/BlazorWebcamApp
The .NET solution: The webcam is queried here with the OpenCvSharp Library. This probably requires significantly more memory and energy. My memory grows to about 1.1 GB. But also not higher after longer use. So no program crash. This solution is interesting if you need to access the n byte stream with C#.
The native HTML5 solution: Here I call up the webcam using the HTML5 standard function via JavaScript. Here I notice that significantly less memory and energy is needed. The consumption is a little over 300 MB. Disadvantage, you can hardly access the bytes via C#. It would also be possible but more complicated.
So it's not a memory leak from Electron.NET or the native Electron under the hood.
@xiaoxinxing12 commented on GitHub (Mar 29, 2023):
Thank you for answering my question so quickly. I have tested the demo you provided, which has resolved my doubts. I have never worked with Blazor before, and this development mode is fantastic. Thanks again and I wish you a successful work and a happy life.