In a VB6 application, I have a Dictionary whose keys are Strings and values are instances of a custom class. If I call RemoveAll() on the Dictionary, will it first free the custom objects? Or do I explicitly need to do this myself?
Dim d as Scripting.Dictionary d('a') = New clsCustom d('b') = New clsCustom ' Are these two lines necessary? Set d('a') = Nothing Set d('b') = Nothing d.RemoveAll
Yes, all objects in the
Dictionarywill be released after a call toRemoveAll(). From a performance (as in speed) standpoint I would say those lines setting the variables toNothingare unnecessary, because the code has to first look them up based on the key names whereasRemoveAll()will enumerate and release everything in one loop.