Board index » delphi » TBitmap does not release Window handles

TBitmap does not release Window handles

Hi there!

Perhaps more people than me have problems
like 'Out of system resources' when
trying to allocate bitmap objects

In my Delphi 1.0 program I have statements like this:

  myBitMap := TBitMap.Create;
  myBitMap.LoadFromFile( ..... );
  myBitMap.Free;

I loop this sequence and after a while errormessage
'Out of system resources' comes up.

Does anyone know if I'm doing wrong or if it is
a bug of some kind.

Thanks
Dan Erik

 

Re:TBitmap does not release Window handles


I'm pretty sure you have to release the windows handle manually. I think
the documentation on TBitMap goes into that a bit or it wouldn't be in
my mind that I had to do it once...

I believe you can use TImage instead and it will be done for you.

Hope I haven't lead you astray, but no one else answered so I figured maybe
every little bit may help.

Burt

587itf$...@mn5.swip.net>, i...@renove.se (Dan Erik Ollas) writes:

Quote
>Hi there!

>Perhaps more people than me have problems
>like 'Out of system resources' when
>trying to allocate bitmap objects

>In my Delphi 1.0 program I have statements like this:

>  myBitMap := TBitMap.Create;
>  myBitMap.LoadFromFile( ..... );
>  myBitMap.Free;

>I loop this sequence and after a while errormessage
>'Out of system resources' comes up.

>Does anyone know if I'm doing wrong or if it is
>a bug of some kind.

>Thanks
>Dan Erik

Re:TBitmap does not release Window handles


Quote
Dan Erik Ollas wrote:

> Hi there!

> Perhaps more people than me have problems
> like 'Out of system resources' when
> trying to allocate bitmap objects

> In my Delphi 1.0 program I have statements like this:

>   myBitMap := TBitMap.Create;
>   myBitMap.LoadFromFile( ..... );
>   myBitMap.Free;

> I loop this sequence and after a while errormessage
> 'Out of system resources' comes up.

> Does anyone know if I'm doing wrong or if it is
> a bug of some kind.

        If you're actually looping through the above there
should be no problem. I can think of at least two possible
explanations. First, you don't show us the actual loop -
it's possible you're looping through less than you think
you are. If it says

for j:=1 to 1000 do
   myBitMap := TBitMap.Create;
   myBitMap.LoadFromFile( ..... );
   myBitMap.Free;

then you're executing the Create 100 times but the Free only
once - you need a begin..end.

        Also there's an amusing bug in Graphics.pas (in D1) that
leads to a memory leak (I thought it was just memory, not resources!),
but only when the total size of the bitmap data is a multiple of 64KB.
Try a slightly smaller bitmap.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Other Threads