Given that there is a dictionary where a sequence of instances are maintained. Although such instances may remain unused for a considerably long time, since they are referred to by the dictionary (or any other collection type) and due to the fact that a reference to that dictionary is kept alive by its parent, the GC does not attempt to automatically collect such items inside of the collection.
The problem is that, since such instances keep accumulating inside of the collection and remain untouched by the GC, a system may run short in memory after a period of time.
Is there a standard pattern to automatically identify these sorts of unused objects inside of a collection and report them to the garbage collector? (Please note that a GC.Collect()
will is totally useless in this case, alongside with being poisonous for the rest of the code)