Avoiding memory leaks

Mar 4, 2010 at 8:53 PM

I have non-shared parts that I instantiate using "var exp = container.GetExport()" (or one of the generic overloads). After I am done using the instance represented by "exp.Value", what is the proper procedure to clean up? Do I need to call "container.ReleaseExport(exp)"? That implies that I need to maintain a dictionary of part/export pairs so that when an instance of a part is disposed, I can release the export from which it was obtained. Or is this something I don't need to worry about?

Regards,

Ron

Mar 5, 2010 at 5:36 PM

Is there any disposable non-shared parts in the graph? If so, the proper way to clean up is either

 

1 - call ReleaseExport or

2 - dispose the container

 

If your apps maps to small logical work units (like a request in a web app), then you'd be better creating child containers and disposing them.