Quote:Original post by Promit
A GC is always triggered by an allocation, and so it happens in the context that attempted the allocation.
There is no garbage collecting thread. None at all.
Now, the danger is that a GC takes out a lock, so if another thread tries to perform an allocation during a GC, it will block until the GC has finished. Then again, Solaris is the only system I know where malloc doesn't take an exclusive lock on the heap. And a gen0 GC (the only kind that should happen regularly) is really fast. So in .NET an allocation risks incurring a slightly long GC that may block other threads; in native code, every allocation is guaranteed to incur a slightly long linked list traversal that may block other threads.
So you are saying a "new" has nondeterministic duration? That's bad news, for example Java programmers are used to virtually free "new". In fact Java programmers can also use an asynchronous GC. Still probably better than C++, if not for that mutex.
Could C# use multiple stacks, and proper preallocation of memory? What about on stack replacement? Does it have a protection for access into native code? Could programmer choose between fast access into native code, and safe access into native code?
And what about the memory model, did MS properly write the specification?
Of course the major slowdown in GC based languages is when one piece is swapped on the HD, and GC wants to release it at any cost. Considering windoze doesn't have too smart swapping it's bad news.