Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have one performance issue in WPF application which is developed in C#.If i run the project initially it is taking 80 to 90 MB.After application opened,i have one screen which will contain one camera.Then memory keep on increasing.i used GC and Disposable functions.But still third party dll memory allocation is not clearning.

I need help on how to solve the memory leak issues in the application.

Regards,
Kiran.
Posted
Updated 5-Oct-11 22:20pm
v2
Comments
Sergey Alexandrovich Kryukov 6-Oct-11 13:01pm    
What do you mean "used GC"? Usually, the best way to avoid troubles is not touching it.
--SA

1 solution

Sorry to say, as you provide this little information, it's not possible to give you effective help. I can only explain what's involved.

Usually, there is no need to "use GC". GC manages your you managed memory without your help. In rare cases you can improve performance of the software one of System.GC.Collect and/or other methods, but it's even easier to make worse. Also, you can create managed memory leaks despite of GC. Usually it happens due to mistakes in design. Remember, GC will collect only the objects not accessible from the code running in the Application Domain. For example, some hold objects by referencing them in some singleton objects with the lifetime about the lifetime of the application. If you forget to remove references of the logically unused object, references will be accumulated in the singleton object and never released nearly until the end of application lifetime. This is a real memory leak, because functionality do not use the objects, they are just created consuming memory until it is exhausted. The design should work carefully with objects of prolonged lifetime. One way of addressing this problem is using weak references, see http://msdn.microsoft.com/en-us/library/ms404247.aspx[^].

The interface System.IDisposable is not related to memory, but disposing can involve releasing of memory. The method System.IDisposable.Dispose is something which is supposed to be called when an object is no longer needed, no matter what. That said, it should be disposed if an exception is thrown, which is often overlooked. For stack objects, using statements should be used (not to be mixed with using, http://msdn.microsoft.com/en-us/library/yh598w02.aspx[^]. This is actually some syntactic sugar strictly equivalent of using disposable object under try-finally block. Being such a sugar, it really helps.

Now, unmanaged memory. If your 3-rd party DLL leaks memory, it leaks it. All you can do is to learn the usage of the library better and learn its memory usage. Maybe you don't use it properly. As I have no idea even what it is, you might need to address this 3-rd party for support. In my experience, the prospects of such support are not very promising in many cases :-<.

That's all.
—SA
 
Share this answer
 
v4

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