Hello everyone,
I am migrating from C++ to C#. Two questions about memory footprint of Dictionary class object instance.
1.
If I call remove method to remove some elements from the Dictionary, will the memory footprint be reduced? (suppose there is no other reference to the removed item) I have some suspecision that Dictionary is not truly removing the element and just mark a flag or something, which still refer this removed item to block it from GCed.
2.
I have two ideas to reduce memory footprint of Dictionary, one is mentioned in (1), to remove some entries. The other is to create a new Dictionary instance, and insert only necessary items into the new Dictionary instance, and reference only the new Dictionary instance in the future.
Which way is better from memory footprint reduce perspective?
thanks in advance,
George
George GeorgePosted May 25, 2008, 5:44 AM
Hi Ben,
Any ideas to how to monitor the memory? I have never performed memory footprint monitor in C# applications yet. Any tools or APIs could I use?
regards,
George
Ben WatsonPosted May 22, 2008, 9:30 PM
I used reflector to examine the code for Dictionary<,>.Remove and it does indeed remove the value. However, the answer to the larger question is probably doing an experiment to see if there is a difference either way, and if that difference is significant (I suspect not).