Let’s say i’m trying to allocate 100 bytes, but since I don’t have 100 bytes available in my GC heap, a garbage collection is triggered. Also, in my GC heap there’s 100mb worth of unreachable objects. To my understanding, once the GC freed 100bytes, he could decide to stop the collection and continue the program’s execution. So let’s say the GC didn’t freed 50mb worth of objects, that are equal to 100 different objects.
My question is this: does the GC invoke all of the finalizers? even though it isn’t going to delete them? (in this case, the 100 unreachable objects that the GC decided not to delete).
The problem is that anything here could be an implementation detail, and it could be different between x86 / x64 / ia64, server vs workstation (very different GC profile), Mono vs MS .NET, OS version, .NET/CLI major version, .NET/CLI patch version, Compact Framework, Micro Framework, etc.
I don’t think you should assume any specific behaviour, other than “objects with finalizers that are not in use will probably get finalized at some point, but even that isn’t guaranteed”.