Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory usage... #2909

Open
xlsupport opened this issue Jan 7, 2025 · 8 comments
Open

Memory usage... #2909

xlsupport opened this issue Jan 7, 2025 · 8 comments

Comments

@xlsupport
Copy link

xlsupport commented Jan 7, 2025

I applaud FanControl. It's fantastic and very light on CPU resources. But then why is it acceptable to use sooo much memory?
I often see the app using well over 150MB.... even when the UI has not been opened, but the computer has resumed from sleep.

image

As a WPF developer I'm well aware of the intracies of WPf and the near impossible task of releasing memory.
The quick and dirty solution would be to restart the process and shutdown the wpf.application

In the case of FanControl I'm assuming restarting the exe will be too costly. So you'd need to separate out the wpf.App and have a controller thread running the show. Then from the Controller thread you can restart the wpf.app when the MainWindow closes.

Thanks, Jurgen

PS. Please add a manifest and make it DPI V2 aware? Takes a few minutes.

@Rem0o
Copy link
Owner

Rem0o commented Jan 7, 2025

If you "never" open the UI, the process normally consumes a lot less than 150 mb. Once a WPF window has been opened and all the UI resources loaded, then as you said, you can't really control how/when the memory is released.

If you close the window and leave it alone, at some point, it will go down, usually well below 50 mb.

I've already taken quite a bit a time with memory profilers to make sure nothing gets leaked/held in memory when the UI is closed, and I don't think your solution would fix any real "problem" in a normal usage scenario. I prefer to leave it be and let the GC do its thing instead of fighting it over and over.

@xlsupport
Copy link
Author

I justed tested a few things...
as clearly the GC is doing its thing very very lazily on my machine (AMD 5800X on Asus B550 with Nvidia RTX 3080).

Reboot... no UI, two TB temp icons. When it's starting it goes up to 140Mb.. then after a few minutes it settles to around 30Mb.
BUT then I open the Window and WPF kicks in... it grows to 143Mb and that never comes down to below 130Mb. It just doesn't.

So rebooted again, NO UI:
Initial 140Mb drops to 30Mb, Signout/SignIn... and it goes to 150 and stays there... until after 10 minutes GC is indeed kicking in.. and I'm seeing a steady drop to 30Mb

Open & Close UI: 130Mb. Waited 5 mins. 110Mb. Waited another 5 mins... Permanent. That's WPF, no doubt.
Signout/SignIn: 143Mb. Waited 5 mins. 148Mb. Waited another 5 mins... and THEN I saw it starting coming down.. slowly.

If you;re interested I could write you a prototype for my "Controller" scenario, which runs the Wpf.Application on a separate thread when needed only. And shuts it down when the window closes...

@Rem0o
Copy link
Owner

Rem0o commented Jan 7, 2025

I would be curious if you could try it with the https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit wpf test app.

Should be a relevant test for FanControl, as FanControl uses the same UI library.

@xlsupport
Copy link
Author

For my info is your app plain .Net or .Net Framework? And I'll test with a few XAML design frameworks.

@Rem0o
Copy link
Owner

Rem0o commented Jan 7, 2025

There are two builds: 4.8 and .NET 8

@xlsupport
Copy link
Author

Lol... I've never used that particular toolkit. I've seen easier ones ;-)
Also realized that I can't create Appdomain in NET, only in FW... I'll dive back in this evening ;-)

@xlsupport
Copy link
Author

@Rem0o Et voila!
It's not the Controller scenario I set out to build, but it does reduce memory on load and on Window.Close()

MemDemo.zip

@Rem0o
Copy link
Owner

Rem0o commented Jan 8, 2025

Looked at the code, but basically all I'm seeing is lazy loading the UI stuff, which I already do, and then the only meaningful thing is "SetProcessWorkingSetSize", which I need to do some research on, as it seems quite a bit of a hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants