WPF Application takes too much RAM usage than Winform, how can I optimize WPF App's memory usage? #9017
Replies: 1 comment 3 replies
-
@neville-studio Given that memory measurement is a complex topic, to avoid any misunderstandings due to differing perceptions, I highly recommend you try out a simple application. For instance, the code I provide below is a WPF window program that launches through the console, located in Program.cs. This is a very straightforward application, please ensure to switch to the x86 platform and run it after releasing it. After running, you can try to observe the size of the memory occupied by this process. To avoid causing you any confusion, I have also uploaded all the code from my project to GitHub. You can download all the files from my project, open the HayceewiballfergeBawbalhega.sln file in VisualStudio, then switch to Release mode to build and run the application by double-clicking the exe file in Explorer, independent of VisualStudio. using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace HayceewiballfergeBawbalhega;
class Program
{
[STAThread]
static void Main()
{
// Enable SoftwareOnly RenderMode to avoid hardware effect.
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
var application = new Application();
application.Startup += (s, e) =>
{
new Window()
{
Width = 200,
Height = 100,
}.Show();
};
application.Run();
}
} |
Beta Was this translation helpful? Give feedback.
-
I have used .NET 8.0 to build two blank applications, the one is WPF application, the another one is WinForm, then publish these applications.
The WPF Application takes too much memory, more than 90MB memory used, but the WinForm application only takes 6.0MB - 7.0 MB memory usage.
So I want to ask how to optimize WPF Application's memory usage if I want to develop a tool app.
Beta Was this translation helpful? Give feedback.
All reactions