daelmo wrote:
CollectionCore.Dispose releases unmanaged and managed resources. IMHO you don't need to worry about that if your EntityCollections go out of scope eventually, which will dispose them automatically. What is your concern about this?
My concern was for memory footprint and memory leaks. Our application does not dispose of these collections in many places. Our object graph for our entities is quite large so entities or their members hanging on to memory is concerning.
Otis wrote:
The Dispose() cleans up eventhandlers which are tied to the entities in the collection. So if you keep an entity around which is in a collection, and you get rid of the collection without removing the entity from that collection then the eventhandlers in the collection bound to the events of the entity will keep the collection around (as the entity event references the handler method of the collection). Dispose will unbind the event handlers of the collection bound to the events of every entity in the collection, so if you keep the entities in that collection around, the collection is not kept in memory because of that. It's an edge case, really. Normally you won't run into that situation that much.
This is very clear. I'll communicate it to our team. Thank you.