🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #442

bds2006 vcl, CreateCompatibleBitmap, EOutOfResources

#442
From: 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. 
Technical Details
Message-ID: <480512cb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,88848d407d0d2500,start
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "dhoke" <dhoke.nojunk@east-shore.com>
From: "dhoke" <dhoke.nojunk@east-shore.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: bds2006 vcl, CreateCompatibleBitmap, EOutOfResources
Date: Tue, 15 Apr 2008 16:42:45 -0400
Lines: 47
Organization: East Shore Technologies, Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 68.236.142.50
Message-ID: <480512cb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1208292043 68.236.142.50 (15 Apr 2008 13:40:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail