As you may remember from the previous chapter, gc classes can only be instantiated on the GC heap. However, this is not always what you want. Creating an object on the heap is a costly operation and could trigger garbage collection. Further, accessing a gc object requires a pointer dereference, which doesn’t come free either. Finally, having to use operator new every time you need to create an object would be a nuisance.
KeywordsPrimitive Type Garbage Collector Boxed Type Boxed Versus Object Copying
Unable to display preview. Download preview PDF.