What is the difference between instantiating a .NET object in C ++ that is managed or unmanaged. That is, what are the differences between these statements:
StreamWriter ^stream = gcnew StreamWriter(fileName);
against
StreamWriter *stream = new StreamWriter(fileName);
My assumption is that if I use gcnew, then the memory allocated for StreamWriter will be managed by the garbage collector. Alternatively, if I use a pointer (*) and a new keyword, I will have to call delete to free the memory.
My real question is: will the garbage collector manage the memory that is allocated inside .NET objects? For example, if a .NET object creates an instance of another object and goes out of scope, will the garbage collector manage this memory even if I use a pointer (*) and a new keyword, and NOT gcnew and handle (^).
memory-management pointers visual-c ++ c ++ - cli
Storm kiernan
source share