Index: reactos/ntoskrnl/mm/ARM3/pool.c =================================================================== --- reactos/ntoskrnl/mm/ARM3/pool.c (revision 74313) +++ reactos/ntoskrnl/mm/ARM3/pool.c (working copy) @@ -415,6 +415,67 @@ KeBugCheckEx(BAD_POOL_CALLER, 0x42, (ULONG_PTR)PoolAddress, 0, 0); } + +extern PPOOL_TRACKER_TABLE PoolTrackTable; +extern SIZE_T PoolTrackTableSize; +//extern PPOOL_TRACKER_BIG_PAGES PoolBigPageTable; + +#define PRINT_N_ENTRIES 6 + + +static +VOID +PrintTopPoolUsers(IN SIZE_T SizeInBytes, BOOLEAN Paged) +{ + SIZE_T Sizes[PRINT_N_ENTRIES] = {0}; + ULONG Allocs[PRINT_N_ENTRIES] = {0}; + SIZE_T Indexes[PRINT_N_ENTRIES] = {0}; + SIZE_T n, j; + + /* Are we not actually requesting a too big region? */ + //if (SizeInBytes > PAGE_SIZE * 100) + // return; + + //__debugbreak(); + + for (n = 0; n < PoolTrackTableSize; ++n) + { + if (!PoolTrackTable[n].Key) + continue; + + for (j = 0; j < PRINT_N_ENTRIES; ++j) + { + SIZE_T CurrentSize = Paged ? PoolTrackTable[n].PagedBytes : PoolTrackTable[n].NonPagedBytes; + ULONG CurrentAlloc = Paged ? PoolTrackTable[n].PagedAllocs : PoolTrackTable[n].NonPagedAllocs; + if (CurrentSize > Sizes[j]) + { + if (j+1 < PRINT_N_ENTRIES) + { + memmove(Sizes + j + 1, Sizes + j, sizeof(SIZE_T) * (PRINT_N_ENTRIES - j - 1)); + memmove(Allocs + j + 1, Allocs + j, sizeof(ULONG) * (PRINT_N_ENTRIES - j - 1)); + memmove(Indexes + j + 1, Indexes + j, sizeof(SIZE_T) * (PRINT_N_ENTRIES - j - 1)); + } + Sizes[j] = CurrentSize; + Allocs[j] = CurrentAlloc; + Indexes[j] = n; + break; + } + } + } + + DbgPrint("Top %d %sPaged pool users:\n", PRINT_N_ENTRIES, Paged ? "" : "Non"); + DbgPrint("Tag Allocs Bytes\n"); + + for (j = 0; j < PRINT_N_ENTRIES; ++j) + { + if (!Sizes[j]) + continue; + n = Indexes[j]; + DbgPrint("%.4s %10u %14u\n", &PoolTrackTable[n].Key, Allocs[j], Sizes[j]); + } + DbgPrint("\n"); +} + PVOID NTAPI MiAllocatePoolPages(IN POOL_TYPE PoolType, @@ -493,8 +554,9 @@ // // Out of memory! // - DPRINT1("OUT OF PAGED POOL!!!\n"); + DPRINT1("OUT OF PAGED POOL!!! (Requested %lu bytes)\n", SizeInBytes); KeReleaseGuardedMutex(&MmPagedPoolMutex); + PrintTopPoolUsers(SizeInBytes, TRUE); return NULL; } @@ -610,8 +672,9 @@ // // Out of memory! // - DPRINT1("OUT OF PAGED POOL!!!\n"); + DPRINT1("OUT OF PAGED POOL!!! (Requested %lu bytes)\n", SizeInBytes); KeReleaseGuardedMutex(&MmPagedPoolMutex); + PrintTopPoolUsers(SizeInBytes, TRUE); return NULL; } }