-
June 17th, 2006, 02:03 AM
#1
[RESOLVED] Why .Net not use smart pointers instead of GC?
Hi, my question is why didn't .Net use smart pointers instead of Garbage Collector to do memory management?
In that way, the memory will reclaimed automatically when there is no variable reference the object, and memory usage will be always compact, and there is no need for a garbage collector program running.
Thanks for answering my query!
-
June 17th, 2006, 09:45 AM
#2
Re: Why .Net not use smart pointers instead of GC?
Originally Posted by CBasicNet
Hi, my question is why didn't .Net use smart pointers instead of Garbage Collector to do memory management?
Although I'm not in the VC++ team, I can answer that for you:
The reason is that smart pointers (or more generally speaking: object reference counting), as used in VB 6, fail to handle the case of circular object references - they will normally lead to orphaned resources. That's where garbage collection comes in (not only with regard to .NET, but in a very general sense: It's the reason why GC had to be invented after all, and is also used by other languages / environments, like Smalltalk for example).
-
June 17th, 2006, 09:57 AM
#3
Re: Why .Net not use smart pointers instead of GC?
Hi: I'm Jonathan Caves and I'm a developer on Visual C++ compiler team.
The reason that the .NET runtime uses a garbage collector is that it is desgined as multi-language runtime: as well as C++ it supports VB, C#, Eiffel, Cobol, and other languages. So you can't really use a C++ specific technology like smart-pointers (which require templates) for a language neutral technology like the .NET runtime. Having said that I am more that certain that the .NET runtime itself, which is mostly written in C++, makes use of smart pointers internally.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|