How to free memory in a WPF application in C#? [closed]

closed . This question needs details or to be clearer and is not currently accepting answers.

want to improve this question? Add details and make it clearer what problem is being solved by editing this post .

Closed 8 months ago .

improve this question

Well I created a system in WPF and C # and with each passing day it gets bigger, I honestly had never worried about the memory issue for small applications does not make much difference, but it is not the case.

Now I have the following situation, some people stay days with the system open and it will only consume memory until an hour comes that bursts and it closes.

There is not enough quota to process this command [Memory: 739614720] in MS. Win32.UnsafeNativeMethods.PostMessage (handleref hwnd, WindowMessage msg, IntPtr wparam, IntPtr lparam) in System.Windows.Interop.HwndTarget.UpdateWindowSettings (Boolean enableRenderTarget, Nullable`1 channelSet) in System.Windows.Interop.HwndTarget.UpdateWindowPos (IntPtr lParam) in System.Windows.Interop.HwndTarget.HandleMessage (WindowMessage msg, IntPtr wparam, IntPtr lparam) in System.Windows.Interop.HwndSource.HwndTargetFilterMessage (intptr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean & handled) in MS. Win32.HwndWrapper.WndProc (intptr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) in MS. Win32.HwndSubclass.DispatcherCallbackOperation (Object o) in System.Windows.Threading.ExceptionWrapper.InternalRealCall (Delegate callback, object args, Int32 numArgs) in System.Windows.Threading.ExceptionWrapper.TryCatchWhen (Object source, Delegate callback, object args, Int32 numArgs, Delegate catchHandler)

I did a little research and from what I saw it was for the GC to do the" cleaning " automatically, but it's not what it is happen. I also called Dispose in some DataBase classes but it didn't help much either.

I debugged the system and simulated some situations

insert the description of the image here

Even if I close the tab or change the order of service I realized that really the memory does not clean.

Does anyone have any idea what I can do to improve this situation.

I took some logs and this error happens in people who stay with the system several days open usually 2 or 3 days, it does not pass this because it bursts the KKK memory.

In a company of 60 employees it happens about 2 or 3 times a day in all, but I would like to optimize the code, because the system will grow and this problem can get serious in the future.

I have researched about memory leak and I believe I have reached the problem

Https://blog.jetbrains.com/dotnet/2014/09/04/fighting-common-wpf-memory-leaks-with-dotmemory/

Seems to be related to RadGridView's x:Name, I did some testing and apparently improved the scenario but I'm still parsing.

Author: Nayara Ferreira de Jesus, 2020-06-05