Not able to allocate NonPaged/Paged memory above 2047 MB on 64-bit Windows IoT OS inside WDM Driver

Refresh

April 2019

Views

4 time

0

As per my knowledge in Windows 64-bit architecture we can assign nonpaged memory upto 75% of RAM or 128 GB (Whichever is lower)

https://blogs.technet.microsoft.com/markrussinovich/2009/03/10/pushing-the-limits-of-windows-paged-and-nonpaged-pool/

https://docs.microsoft.com/en-us/windows/desktop/memory/memory-limits-for-windows-releases

However while trying to allocate nonpaged memory pool more than 2047 MB below code print “2048 MB NonPagedPool memory is not allocated.” in debugview. Why? Please help!!

Environment

5 GB RAM, Visual Studio 2017, Windows 10 IoT 64-bit, Inter i5 Processor

Solution which I already tried.

  1. Enabled LARGEADDRESSAWARE.

  2. Changed Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management Keys (NonPagedPoolSize, NonPagedPoolQuota)

  3. Checked Maximum limit of paged/nonpaged pool through windbg "!vm extension" command; how much nonpaged memory is currently in used through task manager.

  4. Tried all relevant function to allocate memory which are MmAllocateNonCachedMemory, MmAllocateContiguousMemorySpecifyCache, and ExAllocatePoolWithTag.

  5. Tried to allocate paged memory above 2047 MB but failed.

Code

#include "ntddk.h"
PVOID AllocatedMemory = NULL;
VOID Unload(PDRIVER_OBJECT DriverObject)
{
if (AllocatedMemory != NULL)
{
ExFreePoolWithTag(AllocatedMemory, 'Tag1');
KdPrint(("2048 MB NonPagedPool memory is freed. \r\n"));
}
}

NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
NTSTATUS status = STATUS_SUCCESS;
DriverObject->DriverUnload = Unload;
AllocatedMemory = ExAllocatePoolWithTag(NonPagedPool, 2048 * 1024 * 1024, 'Tag1');
if (AllocatedMemory != NULL)
{
KdPrint(("2048 MB NonPagedPool memory is allocated. \r\n"));
}
else
{
KdPrint(("2048 MB NonPagedPool is not allocated. \r\n"));
}
return status;
}

0 answers