Click to See Complete Forum and Search --> : How To Free Memory With C++/CLI


2MuchRiceMakesMeSick
January 7th, 2007, 09:47 PM
I know that the memory is managed but I have a program that uses classes/inheritance and each class is at least 100 variables deep. When you use several intances sometimes 50+ deep how can I tell the OS that I am done with that memory?

My program uses ALOT of memory and I am trying to cut it down.
I am using gcnew to declare my classes


Thanks in advance.

Zaccheus
January 8th, 2007, 04:04 AM
There's a method which forces garbage collection (System::GC::Collect (http://msdn2.microsoft.com/en-us/library/system.gc.collect.aspx)) but it is generally recommended to just let the garbage collector do its job automatically.

2MuchRiceMakesMeSick
January 8th, 2007, 06:20 PM
how does the gc know what variables it can collect?

cilu
January 9th, 2007, 04:59 AM
See this articles:

http://msdn.microsoft.com/msdnmag/issues/1100/GCI/default.aspx
http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/
http://www.csharphelp.com/archives2/archive297.html