View Full Version : managed C++ and memory management

02-17-2005, 05:49 AM
This is a two parter, relating to my now having moved to managed C++ from a unmanaged C++ world.

(1) This is an example that will clarify my understanding of how managed C++ works. Say I have an ArrayList and I Add(new SomeManagedObject()) a bunch of times, then I call Clear() on the ArrayList. All the managed objects I added to the ArrayList will eventually be garbage collected, right?

(2) What tools are available to disagnose memory usage on a managed .net C++ program? I'm finding that even though I religiously delete any unmanaged object I create, and leave managed objects up to garbage collection, my app's memory usage often creeps upward. Especially for functions that do things like I mentioned in (1), where I clear a collection and re-populate it with data. Even forcing a GC::Collect() doesn't seem to reduce memory consumption. If I run my app under VS's debug, it doesn't report any leaked memory.

Thanks in advance!