The application was running perfectly fine without any memory issue or hang issue with Win Controls using C#,Entity Frame Work 4.5 and Sql Server 2012 on Client system.
we convert Application into to Telerik Controls after That the experience was not good.
1) First it uses memory too much and after some time it show Out Of memory exception.
For this Purpose on each Form closing Event we used this class code.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
MemoryManagement.FlushMemory();
}
after using this code the problem Out Of memory exception went away.But we are still facing after some hours the Application get stuck but in task Manager it show normal Memory using no Hang issue but we try to use Application it work very slow even we try to write in textbox it write very slow.
Please suggest some solution :)
What I have tried:
public class MemoryManagement
{
[DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet =
CharSet.Ansi, SetLastError = true)]
private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int
maximumWorkingSetSize);
public static void FlushMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
}