add instrumentation to diagnose failed VM commit

This was SVN commit r10405.
This commit is contained in:
janwas
2011-10-15 22:03:42 +00:00
parent 3624f7c417
commit 6c102ea712
3 changed files with 14 additions and 0 deletions
+4
View File
@@ -109,7 +109,11 @@ Status da_set_size(DynArray* da, size_t new_size)
bool ok = true;
// expanding
if(size_delta_pa > 0)
{
ok = vm::Commit(uintptr_t(end), size_delta_pa);
if(!ok)
debug_printf(L"Commit failed (%p %d)\n", end, size_delta_pa);
}
// shrinking
else if(size_delta_pa < 0)
ok = vm::Decommit(uintptr_t(end+size_delta_pa), -size_delta_pa);
+3
View File
@@ -247,7 +247,10 @@ public:
{
T* t = (T*)pool_alloc(&m_pool, count*sizeof(T));
if(!t)
{
debug_break();
throw std::bad_alloc();
}
return t;
}
+7
View File
@@ -238,6 +238,13 @@ static void* AllocateLargeOrSmallPages(uintptr_t address, size_t size, DWORD all
statistics[processor].NotifySmallPageCommit();
return smallPages;
}
else
{
MEMORY_BASIC_INFORMATION mbi = {0};
SIZE_T ret = VirtualQuery(LPCVOID(address), &mbi, sizeof(mbi));
debug_printf(L"Allocation failed. VirtualQuery returned %d\n", ret);
debug_printf(L"base=%p allocBase=%p allocProt=%d size=%d state=%d prot=%d type=%d\n", mbi.BaseAddress, mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.State, mbi.Protect, mbi.Type);
}
return 0;
}