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

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

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 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 NonCachedMemory is allocated. \r\n"));

            }

            else

            {

                            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

Comments

  • anton_bassovanton_bassov Member Posts: 4,983

    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
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA