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,66 @@ 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) +{ + struct + { + SIZE_T Size; + ULONG Allocs; + SIZE_T Index; + } Top[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 > Top[j].Size) + { + RtlMoveMemory(&Top[j + 1], &Top[j], sizeof(Top[0]) * (PRINT_N_ENTRIES - j - 1)); + + Top[j].Size = CurrentSize; + Top[j].Allocs = CurrentAlloc; + Top[j].Index = 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 (!Top[j].Size) + continue; + n = Top[j].Index; + DbgPrint("%.4s %10u %14Iu\n", &PoolTrackTable[n].Key, Top[j].Allocs, Top[j].Size); + } + DbgPrint("\n"); +} + PVOID NTAPI MiAllocatePoolPages(IN POOL_TYPE PoolType, @@ -493,8 +553,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 +671,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; } }