Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am novice to Win Forms. My application keeps on building up memory and not releasing it back to system. I have tried disposing off all the datasets created and the forms have been closed and disposed. Somehow the Garbage Collector is not freeing up the memory.
I have used the memory profilers and find that the queries build for the datasets are still kept in the memory.
I suspect the big "aaa.xsd" files that are formed to create huge query strings - that are "User Non debugger code"......what system did generate when doing the datasets.
Is their any way to clear off the query strings , that is what I suspect is holding up the memory.
I hope I have put up the question in a detailed fashion. Please feel free to ask more questions if need be.
Thanks for reading this and replying.
Posted

If you're looking in TaskManager, that's your first mistake.

Your code runs in a type of virtual machine, managed by the .NET CLR (Common Language Runtime). The CLR maintains a "managed" heap of memory for your application to use. That heap is allocated out of memory handed over by Windows.

When your code runs, it starts allocating its object out of the managed pool of memory. If the managed pool runs low on free memory, the CLR asks Windows for more memory and adds it to the managed heap.

Task Manage is showing you the memory reserved for your application, not what it is actually using!

When your application frees objects, the memory goes back into the managed heap, not back to Windows.

The .NET CLR does a very good job of managing memory. If Windows needs memory back form the CLR, the CLR is more than happy to return whatever memory it can, which is usually a pretty good sized chunk.

If you want to see how much memory your code is really using, use PerfMon and the .NET Memory counters.
 
Share this answer
 
I have used a memory profiler (Redgate ANTS) to profile the application.
The CLR is obviously not doing the right thing not releasing enough memory into the OS.
Is it a flaw with Win Forms that it acquires lots of memory to run?
Web Apps are better in case of memory utilisation ??

I hsve tried practically every optimisation technique and the memory still keeps piling up.
 
Share this answer
 

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