Garbage Management wpf
Hi, I'd like to know how to manage process memory in my software. Here is some code that has a constructor with a
modalNavigationStore
parameter, which is a singleton that I never dispose of. I'd like to know if I need to set _modalNavigationStore = null
to ensure proper disposal and garbage collection when i'm done with my service ?
20 Replies
You shouldn't need to. Is this service consumed as a singleton as well?
nop this is a transient
Either way, unlikely to make a difference as you stated
ModalNavigationStore
is a singleton.
You'll usually only have to be concerned with memory management when interacting with unmanaged resources (like files, for example).um ok because I feel like i have a memory leak problem and I'm trying to understand what my problem could be
What makes you feel like you have a memory leak problem?
And assuming you are using visual studio or rider, you should be able to use either's memory profiler to view memory usage in real time when debugging.
The process memory in the diagnostic tools keeps increasing and sometimes never goes down
What IDE are you using?
visual studio 2022
Then I'd recommend you take advantage of the snapshot feature it has. Start your WPF app, click around for a minute or so, and take a memory snapshot. Then click around for a few more minutes until your memory usage noticeably increases and take another snapshot. You should be able to view the difference between each one and see exactly what is causing the increase.
Analyze memory usage in the Performance Profiler - Visual Studio (W...
Learn how to use the Memory Usage tool without the debugger in the Visual Studio Performance Profiler to monitor your app's memory use.
i'm going to take a look to this article because i got this and i can't understand anything for the moment ahah
do you know if hot reaload could be a problem ? should i turn it off ?
That's because you're looking at a single snapshot in this picture. You'd need two snapshots, open the latest one and select the first one in the
Compare With Baseline
option in the top right.
No point in making guesses when you have the tools to give you a proper answeri'll try my best to understand all of this and come back if i need further help. Thanks
:PepoSalute: good luck
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
It wasn't the full code, I've reduced the size of the file to make my question easier to understand but ok
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Well I'll remove the regions then, I was using rrgion just to sort the code into private, public method and fields