> Is there anything wrong with creating another instance of a bitmap even if
> its created?
> I get no error message if I do this.
> eg earlier call:
> bitmap := Tbitmap.Create;
> secondary call
> bitmap := Tbitmap.Create;
> without a free in between
> Since bitmap is a pointer to the same memory location it should be ok
right?
no error but then you're not recovering the memory fromt he first bitmap
either.
Here's an example
var
BM :TBitmap;
begin
// At this point no main memory has been used (there are four bytes used
on the stack for the BM variable)
BM := Tbitmap.create;
// An instance of TBitmap has been created - the address that this
instance resides in has been placed in BM
// This means that 2 pieces of memory are used 4 bytes on the stack and a
Tbitmap sized chunk from the heap.
BM := Tbitmap.create;
// An instance of TBitmap has been created - the address that this
instance resides in has been placed in BM
// There are now three pieces of memory used BM on the stack and 2
TBitmap sized chunks from the heap.
// Since BM 'points' to the second chunk from the heap there is now no
way to 'free' the first chunk.
end;
If this didn't use any memory then this wouldn't hurt;
var
BM :TBitmap;
I :Integer;
begin
for I := 0 to 10000000 do BM :=TBitmap.Create; // ;)
end;
he he he
Memory go bye bye...
--
Aaron@home
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz