Click here to Skip to main content
15,799,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)

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

       public static void FlushMemory()
           if (Environment.OSVersion.Platform == PlatformID.Win32NT)
               SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
Updated 27-Sep-16 21:58pm
Thomas Nielsen - getCore 28-Sep-16 3:37am    
You should not manually handle memory (almost) ever in CLR, when you do GC.Collect() your runtime will freeze all processes whilst compiling dependency tree for objects (to see if they're referred from active user space still or can be reclaimed)
What you should do is make sure that all Disposable controls are disposed when you form close or you're in for it, having to wait until the GC thread finds out that you're not using the objects, have an event listener you forgot to detach somewhere and it'll never happen!
I think it will be a good idea to add the code that actually fails and not your work-around trying to mitigate something which is likely to be a problem in the usage pattern. IF there is indeed a memory issue with Telerik controls, do report it to them, they have presumably a huge attention to remaining relevant to their customers, by producing quality.
Jawad Ahmed Tanoli 28-Sep-16 4:21am    
Thanks for reply i remove manually MemoryManagement class and test it again .
Richard Deeming 28-Sep-16 9:21am    
Telerik controls are commercial components, so presumably they come with support?

The controls aren't open-source, so the only people who can fix problems with them are Telerik.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900