Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why does CreateCompatibleBitmap fails if there is 'enough' memory?

388 views
Skip to first unread message

Laszlo Nagy

unread,
Sep 16, 2003, 7:17:39 AM9/16/03
to
Hi!
I've got 512MB Physical Memory, Win2000 and Visual Studio
6.0. When I start my program Windows Task Manager shows
that MEM Usage is about 108MB.
I'd like to create a big bitmap for flickerless animation.
I call CreateCompatibleBitmap with very big values, for
example CreateCompatibleBitmap(hdc,4000,4000), where hdc is
a 32bpp Private Display Device Context. The function
returns NULL, then GetLastError() returns 8, which means
"Not enough storage is available to process this command".
Then I call malloc(4000*4000*4) and it returns non-NULL,
which shows that there's enough memory.
The problem doesn't occur if I create smaller (for example
1000*1000) bitmap.
I couldn't find any information concerning this problem on
MSDN.
Laszlo

Scott McPhillips

unread,
Sep 16, 2003, 8:25:54 AM9/16/03
to

I'm just guessing here - but some of the bitmap commands attempt to
allocate the memory in kernel storage for blitting efficiency.

--
Scott McPhillips [VC++ MVP]

John Hornick [MSFT]

unread,
Sep 16, 2003, 9:40:06 AM9/16/03
to
Hi,


DDBs are allocated by the driver for the reference DC. This allocation
is made from paged pool. On a machine with that much memory, I would
think your paged pool would be around 192 MB. From that, all such
allocations (and anything else any drivers allocate) must come. So
you can't have a bitmap which exceeds that size, and you can't have
several bitmaps which collectively exceed that size.

On Terminal Server machines, this limit is exaggerated because of how
that pool is shared. There, you'll see a limit of around 28Mb.

This is by design. If you require larger bitmaps in these scenarios,
use DIBSections.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

Laszlo Nagy

unread,
Sep 16, 2003, 10:45:02 AM9/16/03
to
>-----Original Message-----
>DDBs are allocated by the driver for the reference DC.
This allocation
>is made from paged pool. On a machine with that much
memory, I would
>think your paged pool would be around 192 MB. From that,
all such
>allocations (and anything else any drivers allocate) must
come. So
>you can't have a bitmap which exceeds that size, and you
can't have
>several bitmaps which collectively exceed that size.
>
>On Terminal Server machines, this limit is exaggerated
because of how
>that pool is shared. There, you'll see a limit of around 28Mb.
>
>This is by design. If you require larger bitmaps in these
scenarios,
>use DIBSections.
>
>Thanks,
>- John

Is there any way to influence the size of the paged pool?
Is there any relation between the size of the physical
memory and the size of the paged pool? Are they independent?
Thank you very much, John!

John Hornick [MSFT]

unread,
Sep 16, 2003, 11:58:07 AM9/16/03
to
Hi,

Paged pool size is a fixed function of the amount of memory
installed on the machine. And there is a point of diminishing
returns, above which the paged pool either doesn't grow or
grows slowly. To my knowledge, you cannot influence it, except
as noted above.

If I were you, I'd just use DIBSections.

Thanks,
- John


Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

Feng Yuan [MSFT]

unread,
Sep 17, 2003, 3:16:12 AM9/17/03
to
I tested the latest DDB on Windows NT/2000 before. For 32-bpp, it's 3072 x
3072 = 36 MB.

I guess David Solomon's books mentions that paged pool is a fixed region
within kernel mode address space. The whole kernel mode address space is
only 2 GB, shared by system kernel DLLs, pagining tables, kernel mode
drivers, paged pool and non-paged pool. So it's quite crowded. The size of
paged pool is limited by kernel mode address space.

--
Feng Yuan (www.fengyuan.com)

Laszlo Nagy

unread,
Sep 17, 2003, 4:12:01 AM9/17/03
to
>If I were you, I'd just use DIBSections.

Hi!
I wanted flicker-free drawing and I've done it with the
help of the following technical article:
http://msdn.microsoft.com/library/en-us/dngdi/html/msdn_flicker.asp
This article implements drawing to off-screen memory with
DDBs. Is there any article discussing the way how one can
draw to off-screen memory using DIBSection?
Thank You!

John Hornick [MSFT]

unread,
Sep 17, 2003, 1:25:48 PM9/17/03
to
Hi,


It's the same approach. Replace your call to CreateCompatibleBitmap()
with a call to CreateDIBSection(). Everything else remains the same.

Laszlo Nagy

unread,
Sep 18, 2003, 3:44:45 AM9/18/03
to
>It's the same approach. Replace your call to
CreateCompatibleBitmap()
>with a call to CreateDIBSection(). Everything else remains
the same.

Thank You very much, it works!

0 new messages