GC::PleaseRunWhenProcessRunningOutOfMemory()

I don’t think anybody except the guys who coded the GC knows the list of triggers for garbage collection. I believe it’s not part of the CLR spec and I guess that was a deliberate decision to allow implementors flexibility in their GC algorithms. That said, there are some situations which leave one confounded as to why the heck the GC doesn’t run. Take a look at the following program.#include “stdafx.h” #include “windows.h” using namespace System; ref class Allocator { LPVOID ptr; public: Allocator() { ptr = VirtualAlloc(NULL, 1024 * 1024 * 1024, MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (ptr == NULL) Console::WriteLine(“Virtual Alloc failed”); … Continue reading GC::PleaseRunWhenProcessRunningOutOfMemory()