🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by dhoke Tue, 15 Apr 2008 20:42
bds2006 vcl, CreateCompatibleBitmap, EOutOfResources
#442
Author: dhoke
Date: Tue, 15 Apr 2008 20:42
45 lines
2840 bytes
Given the details below, what resource is insufficient?  What can I do to 
avoid the out of resource error/exception (that from my current analysis 
doesn't really seem to exist)?

Thanks.

WindowsXP sp2. machine has 2GB ram. Probably within a month of current OS 
patches.

The following code (except for ? marks) is from (bds2006) vcl's 
Graphics.pas:
  ScreenDC := GDICheck(GetDC(0));
  NewImageDC := GDICheck(CreateCompatibleDC(ScreenDC));
  with DIB.dsbm do
  try
    if DIB.dsbmih.biSize < DWORD(sizeof(DIB.dsbmih)) then
      if (bmPlanes or bmBitsPixel) = 1 then // monochrome
        Result := GDICheck(CreateBitmap(bmWidth, bmHeight, 1, 1, nil))
      else  // Create DDB
???        Result := GDICheck(CreateCompatibleBitmap(ScreenDC, bmWidth, 
bmHeight))
    else  // Create DIB

The ??? marked line of code is reached as a result of doing a 
timageitem->tpictureitem->tbitmapitem->SetSize(wd,ht) call (after any 
previously existing bitmap had already been ->ReleaseHandle()d and 
DeleteObject()d.)  The width/height are 4000/2500.  The desktop screen setup 
has dual monitors with both set at 1280x1024, 32-bit color quality.  (The 
bitmap itself is, or will be, pf8bit, but I don't think that's a factor in 
this area of code.)

The code fails with the GDICheck()) resulting in an EOutOfResources 
exception (the GetLastError() from CreateCompatibleBitmap() (as viewed with 
debugger in GDIError(), called from GDICheck()) appears to be 8.)

Two different tools report a virtual address space free area of size 
527,908,864 (0x1f774000) for the application making the call.

Taskmgr reports approx 500MB free physical memory, about 1.7GB of virtual 
memory available.

Taskmgr reports peak mem usage for the application before failure as 
326,020K.

The scenario has been very reproducible today. 
Re: bds2006 vcl, CreateCompatibleBitmap, EOutOfResources
#443
Author: Remy Lebeau (TeamB)
Date: Tue, 15 Apr 2008 21:42
16 lines
1312 bytes
"dhoke" <dhoke.nojunk@east-shore.com> wrote in message 
news:480512cb$1@newsgroups.borland.com...

> Given the details below, what resource is insufficient?

GDI resources.

> What can I do to avoid the out of resource error/exception
<snip>
> The width/height are 4000/2500.

Don't create such large bitmaps.


Gambit 
Re: bds2006 vcl, CreateCompatibleBitmap, EOutOfResources
#444
Author: Bob Gonder
Date: Tue, 15 Apr 2008 22:10
31 lines
1992 bytes
dhoke wrote:

>Given the details below, what resource is insufficient?
>   Result := GDICheck(CreateCompatibleBitmap(ScreenDC, bmWidth, bmHeight))

>The width/height are 4000/2500.  The desktop screen setup 
>has dual monitors with both set at 1280x1024, 32-bit color quality.

So, you are creating a BMP of 4000 x 2500 x 4 bytes, or 40 MB.

>The code fails with the GDICheck()) resulting in an EOutOfResources 
>exception (the GetLastError() from CreateCompatibleBitmap() (as viewed with 
>debugger in GDIError(), called from GDICheck()) appears to be 8.)

http://support.microsoft.com/kb/928726
CAUSE
This issue occurs if the Graphical Device Interface (GDI) has insufficient memory.

System Error Codes:
http://msdn2.microsoft.com/en-us/library/ms681381(VS.85).aspx

GDI Heap:
http://support.microsoft.com/kb/125699

MS Bug:
http://support.microsoft.com/kb/319740
Another one:
http://support.microsoft.com/kb/299533

Those and more....
http://search.msdn.microsoft.com/Default.aspx?brand=Msdn&refinement=&locale=en-us&lang=&query=gdi
Re: bds2006 vcl, CreateCompatibleBitmap, EOutOfResources
#446
Author: dhoke
Date: Wed, 16 Apr 2008 12:33
47 lines
3142 bytes
Thanks...

"Bob Gonder" <notbg@notmindspring.invalid> wrote in message 
news:1d8a041556ifu53e5i6fm8atmqksriirvs@4ax.com...
>
> So, you are creating a BMP of 4000 x 2500 x 4 bytes, or 40 MB.

Several of them, actually, depending on user input... Some of my test images 
are 8-bit grayscale 8"x8" 1000DPI scans (also measuring 40MB), with the 
provided possibility of something even larger - although that possibility 
may have to be revisited now...

> Those and more....
> http://search.msdn.microsoft.com/Default.aspx?brand=Msdn&refinement=&locale=en-us&lang=&query=gdi
>
The above pointed me to:
http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx

which led me to:
http://blogs.msdn.com/ntdebugging/archive/2006/12/15/getting-ready-for-windows-debugging.aspx

for dheapmon, which produced the results:
R:\kktools\dheapmon8.1\x86>dheapmon
Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation.  All rights reserved.
-------------------------------------------------------------
  Session ID:    0 Total Desktop: (  5824 KB -    8 desktops)

  WinStation\Desktop            Heap Size(KB)    Used Rate(%)
-------------------------------------------------------------
  WinSta0\Default                    3072             99.1
  WinSta0\Disconnect                   64              4.5
  WinSta0\Winlogon                    128             10.2
  Service-0x0-3e7$\Default            512             32.1
  Service-0x0-3e4$\Default            512              8.8
  Service-0x0-3e5$\Default            512              4.3
  SAWinSta\SADesktop                  512              0.5
  __X78B95_89_IW\__A8D9S1_42_ID       512              0.5
-------------------------------------------------------------

99.1% usage is a little tight.

Well, at least now I have some way of quantifying the value, even if I can't 
apparently (safely) determine this directly programmatically.

Wonder how far I could get creating my own "desktop"???  Something to 
explore, I suppose... 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads