This is a migrated thread and some comments may be shown as answers.

memory defragmentation

1 Answer 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andreas Lohr
Top achievements
Rank 1
Andreas Lohr asked on 12 Dec 2009, 12:23 PM

Hello,

we have programed a class library, that has too big memory usage. We have disposed explicit all unmanaged resources like files. We have already taken a look with a memory profiler and its seems the problem is that the GC doesnot clear up the memory or the memory gets defragemented (there are a lot of small pieces of memory and .net allocates always new memory instead of reusing the small free pieces of memory). The process goes up to 2 GB RAM usage, but such amount of memory is never used / needed.

Note: Its a multi-threaded application.

I am out of ideas, what I can try to get the process smaller. All ideas will be appreciated!

Thanks in advance !!

Best regards

Andreas

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 14 Dec 2009, 08:31 AM
Hello Andreas Lohr,

Thank you for contacting us.

Tracking down memory issues is not always straightforward, but here are several tips applicable to .net framework in general:

1) Use the using keyword in C# or the Dispose method when you no longer need resources.
2) Events are one of the key reasons objects do not get collected by the garbage collection so always unsubscribe objects because they will not be collected otherwise.
3) If you have the time and resources, you can consider reducing the memory required by your program in general e.g. cleverer algorithms and less caching.

Do you experience any memory leaks in our controls?

Best wishes,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Andreas Lohr
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or