Article View: borland.public.cppbuilder.nativeapi
Article #7006Memory problems: new versus GlobalAlloc
From: wim bekker wim dv-rec com
Date: Tue, 22 Mar 2005 15:55
Date: Tue, 22 Mar 2005 15:55
25 lines
1941 bytes
1941 bytes
Hi, I'm experiencing some strange troubles with memory allocation. I'm reading in JPG files with Indy from a web camera with HTTP. I receive them in a TMemoryStream. I load them into TJPEGImage. Then Assign it to TBitmap to decode. Then read the bits with GetDIBSizes and GetDIB. Then render the bits with SetStretchBltMode to a TPanel. To get the bits, I need a buffer. If I allocate this with new, SetStretchBltMode failes about 50% of the time. If I allocate with GlobalAlloc, SetStretchBltMode never failes. If I use CodeGuard, things are even worse. I don't know where to begin to ask but lets start with these: What is the difference between new and GlobalAlloc (apart from the fact that Borland or the OS manage it)? Where is the documentation I really need? How come SetStretchBltMode doesn't work good when using memory allocated with new but works fine with memory allocated with GlobalAlloc? Wim.
Technical Details
Message-ID:
<42403f3c@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6b3a605b9bc38024 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "wim bekker" <wim<at>dv-rec<dot>com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Memory problems: new versus GlobalAlloc Date: Tue, 22 Mar 2005 16:55:25 +0100 Lines: 27 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 82.161.70.62 Message-ID: <42403f3c@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1111506748 82.161.70.62 (22 Mar 2005 07:52:28 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail