Allocate a very large block of memory

Was: Allocate more than 100MB

Hello,

i have a little problem with my RAM Disk Driver. The driver uses
ExAllocatePool(NonPagedPool,…) to get the memory. But on systems with
about 768MB memory, the largest available memory block has about 140MB. Some
customers want to create a RAM Disk of about 256MB (or lets say 1/4 to 1/3
of total memory). How can i allocate such a very large memory block ? (This
block must not be continuous, i just need memory which is not paged out or
can kept in memory forever).
I heared it is possible to start Windows with a memory limitation, so the
excluded memory can be used for a RAM Disk. But i don’t know how to get this
memory. Which function must i call to get the excluded memory ?

Any suggestions are welcomed.

Thanks,
A. Roth

>I heared it is

possible to start Windows with a memory limitation, so the
excluded memory can be used for a RAM Disk. But i don’t know
how to get this memory. Which function must i call to get the
excluded memory ?

You have to set /MAXMEM in boot.init to exclude some upper region of
physical memory, which means you have to know how much ram is on the sytem
in order to modify boot.ini and then communicate this configuration to your
driver (like through the registry.) You then have to map the missing ram
into the kernel virtual address space (as if it were device memory,) using
MmMapIoSpace. This is a huge hack, and does not sound like a good solution
for a commercial product UNLESS we are talking about some sort of dedicated
system.

By the way there already is a ‘ram disk’, its called the ‘buffer cache’, and
it works pretty well.

“Andreas Roth” wrote in message news:xxxxx@ntdev…
>
> i have a little problem with my RAM Disk Driver. The driver uses
> ExAllocatePool(NonPagedPool,…) to get the memory. But on systems with
>

PLEASE don’t allocate a big chunk of memory from non-paged pool like that.
Pool is for scratch storage, not for enormous hunks of buffer space.

Assuming we’re talking XP/.NET here, I guess I’d favor using
MmAllocatePagesForMdl(…) – It returns non-paged, zeroed, blocks of
memory. Set low memory address to 0 high to -1, skip to 0… you’re all
set.

Or ZwCreateSection(…), map the section, then lock it.

Or… any of the ten million other ways to allocate memory. But
ExAllocatePool(NonPagedPool,…)?

And Roddy’s right. Please don’t even THINK of using the MAXMEM hack for
this (unless you strictly writing your driver to run on your own development
system :slight_smile:

Peter
OSR