Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

not able to allocate more than 2047MB memory chunk

ashi2109ashi2109 Member Posts: 2

Hi All,

Environment :

virtual machine of Windows 10 IOT x64

Visual studio 2017 community edition

project type : windows driver -> Legacy -> WDM driver

RAM size : 5 GB

Trying to allocate more than 2Gb of memory chunk in physical memory, able to allocate 2047 MB of memory chunk but it fails to allocate any chunk greater that 2047 MB.

but as per Microsoft, on Windows 64-bit architecture we can assign non paged memory up to 75% of RAM or 128 GB
(Whichever is lower)

sample source code is as follows:

include "ntddk.h"

PVOID AllocatedMemory = NULL;



            NTSTATUS status = STATUS_SUCCESS;

            DriverObject->DriverUnload = Unload;

            AllocatedMemory = ExAllocatePoolWithTag(NonPagedPool, 2048 * 1024 * 1024, 'Tag1');

            if (AllocatedMemory != NULL)


                            KdPrint(("2048 MB NonCachedMemory is allocated. \r\n"));




                            KdPrint(("2048 MB NonCachedMemory is not allocated. \r\n"));


            return status;


VOID Unload(PDRIVER_OBJECT DriverObject)


            if (AllocatedMemory != NULL)


                            ExFreePoolWithTag(AllocatedMemory, 'Tag1');

                            KdPrint(("2048 MB NonCachedMemory is freed. \r\n"));



please suggest how can memory chunk more than 2 GB can be allocated.

Thank You


  • anton_bassovanton_bassov Member MODERATED Posts: 5,192

    on Windows 64-bit architecture we can assign non paged memory up to 75% of RAM or 128 GB

    So what???? Even if you have assigned 75% of RAM (i.e 3750 MB in your case) to non-paged pool it does not necessarily imply that all this memory is going to be available to your driver. What about the other drivers that allocate non-paged memory? There is a good chance that 2047 MB of RAM is all that is left in the pool by the time you attempt your allocation. It never occurred to you to think this way, did it..

    KdPrint(("2048 MB NonCachedMemory is allocated. \r\n"));

    ....and, once we are at it, NonCachedMemory and non-paged pool are totally unrelated concepts anyway.....

    Anton Bassov

  • ashi2109ashi2109 Member Posts: 2

    It is confirmed from the windbg (!vm extension) and task manager that sufficient non paged memory is available at the time of memory allocation and also while trying to allocate two chunks of 2047 MB each the memory allocation becomes successful.
    Also while trying to allocate the paged memory the same limitation occurred, 2047 MB memory allocated successfully but failed to allocate any chunk greater than 2047 MB.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE