Tuesday, July 2, 2013

Why there is no garbage collector in ANSI C++?

The reason is that a garbage collector must be able to identify an application’s roots and must also be able to find all object pointers. The problem with unmanaged C++ is that it allows casting a pointer from one type to another, and there’s no way to know what a pointer refers to. In the CLR, the managed heap always knows the actual type of an object and uses the metadata information to determine which members of an object refer to other objects.

No comments:

Post a Comment