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
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
is not related to memory, but disposing can involve releasing of memory. The method
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,
statements should be used (not to be mixed with
]. 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 :-<.