🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.misc
3 messages
3 total messages Started by Boefje Mon, 10 Dec 2001 18:02
Out Of Resources. Any idea why?
#306
Author: Boefje
Date: Mon, 10 Dec 2001 18:02
31 lines
2060 bytes
I use the next code to display a score. The score is a bitmap,
returned by function ScoreBitmap. The bitmap is a standard true color
(24-bits) bitmap.

;------------------------------------------------------------

procedure TForm1.DisplayScore(ai_Team ,ai_Score : integer);
var TmpBmp : TBitmap;
begin
  TmpBmp := TBitmap.Create;
  TmpBmp.Width := ImageScore1.Width;
  TmpBmp.Height := ImageScore1.Height;
  TmpBmp := ScoreBitmap(ai_Score,TmpBmp.Width,TmpBmp.Height);
  ImageScore1.Picture.Bitmap.FreeImage; { usefull?}
  ImageScore1.Picture.Bitmap.Dormant; { usefull?}
  ImageScore1.Picture.Bitmap.ReleaseHandle; { usefull?}
  ImageScore1.Picture.Bitmap := TmpBmp;
  TmpBmp.Free;
end;

;------------------------------------------------------------

After displaying the score many times, I get out of resources
(EOutOfResources). This can only be caused by the created bitmaps. But
I do not understand why. Please explain.

I tried to release the handles of the created bitmaps, but that did
not help. Also, can you explain if the dormant method is of any use to
me? It doesn't seem to harm, but does it help?

Boefje
Re: Out Of Resources. Any idea why?
#304
Author: Michael P. Schneider
Date: Mon, 10 Dec 2001 21:14
28 lines
2240 bytes
> procedure TForm1.DisplayScore(ai_Team ,ai_Score : integer);
> var TmpBmp : TBitmap;
> begin
>   TmpBmp := TBitmap.Create;
>   TmpBmp.Width := ImageScore1.Width;
>   TmpBmp.Height := ImageScore1.Height;
>   TmpBmp := ScoreBitmap(ai_Score,TmpBmp.Width,TmpBmp.Height);
>   ImageScore1.Picture.Bitmap.FreeImage; { usefull?}
>   ImageScore1.Picture.Bitmap.Dormant; { usefull?}
>   ImageScore1.Picture.Bitmap.ReleaseHandle; { usefull?}
>   ImageScore1.Picture.Bitmap := TmpBmp;
>   TmpBmp.Free;
> end;
>
> ;------------------------------------------------------------
>
> After displaying the score many times, I get out of resources
> (EOutOfResources). This can only be caused by the created bitmaps. But
> I do not understand why. Please explain.


Given your code it looks like you are creating a bitmap object in this
procedure.  You are then "losing" the one you created in this procedure by
overwriting it with the retrurn value of the ScoreBitmap procedure.  This is
leaving one TBitmap object unfreed.


Michael P. Schneider
Re: Out Of Resources. Any idea why?
#305
Author: Maarten Wiltink
Date: Mon, 10 Dec 2001 21:25
44 lines
2404 bytes
Boefje wrote in message <287dc9c0.0112101002.6cbc2cb@posting.google.com>...
>I use the next code to display a score. The score is a bitmap,
>returned by function ScoreBitmap. The bitmap is a standard true color
>(24-bits) bitmap.
>
>;------------------------------------------------------------
>
>procedure TForm1.DisplayScore(ai_Team ,ai_Score : integer);
>var TmpBmp : TBitmap;
>begin
>  TmpBmp := TBitmap.Create;

Assign a value to "TmpBmp".


>  TmpBmp.Width := ImageScore1.Width;
>  TmpBmp.Height := ImageScore1.Height;
>  TmpBmp := ScoreBitmap(ai_Score,TmpBmp.Width,TmpBmp.Height);

Assign a different value to "TmpBmp".


>  ImageScore1.Picture.Bitmap.FreeImage; { usefull?}
>  ImageScore1.Picture.Bitmap.Dormant; { usefull?}
>  ImageScore1.Picture.Bitmap.ReleaseHandle; { usefull?}
>  ImageScore1.Picture.Bitmap := TmpBmp;
>  TmpBmp.Free;

Free ONE bitmap.


>end;
>
>;------------------------------------------------------------
>
>After displaying the score many times, I get out of resources
>(EOutOfResources). This can only be caused by the created bitmaps. But
>I do not understand why. Please explain.


Perhaps freeing the first (locally allocated) bitmap would help.

Groetjes,
Maarten Wiltink
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