Hej,
We 're working on an application that displays a lot of data, we have some problems with the memory usage (displaying data in grid, see some linked data, ...) when closing the grid the memory usage does not drop, but when we call the Garbage collector in the disposed event. The memory drops phenomenal.
this is code we execute.
And how we call it in the disposed event
My question is :) is it smart to do so? or if it just a fake solution?
Kind regards.
Greetz,
Jonathan
We 're working on an application that displays a lot of data, we have some problems with the memory usage (displaying data in grid, see some linked data, ...) when closing the grid the memory usage does not drop, but when we call the Garbage collector in the disposed event. The memory drops phenomenal.
this is code we execute.
Code:
[DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize); /// <summary> /// Will request to flush the memory /// </summary> public static void FlushMemory() { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); }
Code:
MemoryManagement.FlushMemory();
Kind regards.
Greetz,
Jonathan
Comment