Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How much memory does a TList eat?

sziszi81sziszi81 Member Posts: 80
[b][red]This message was edited by sziszi81 at 2006-10-23 23:1:39[/red][/b][hr]
[b][red]This message was edited by sziszi81 at 2006-10-23 14:30:21[/red][/b][hr]
this is the declaration of TList:


[code]

const
MaxListSize = Maxint div 16;

type

PPointerList = ^TPointerList;
TPointerList = array[0..MaxListSize - 1] of Pointer;

TList = class(TObject)
private
FList: PPointerList;
FCount: Integer;
FCapacity: Integer;
...

[/code]

That MaxListSize constant is 134217728, a Pointer is stored on 4 bytes
so a TPointerList is stored on 134217728 x 4 = 536870912 bytes????
That is 512 MB of memory!!! PPointerList in change only eats 4 bytes.
Is this a dynamic list for real?
Or how is this? Can anyone explain?






Comments

  • zibadianzibadian Member Posts: 6,349
    : [b][red]This message was edited by sziszi81 at 2006-10-23 14:30:21[/red][/b][hr]
    : this is the declaration of TList:
    :
    :
    : [code]
    :
    : const
    : MaxListSize = Maxint div 16;
    :
    : type
    :
    : PPointerList = ^TPointerList;
    : TPointerList = array[0..MaxListSize - 1] of Pointer;
    :
    : TList = class(TObject)
    : private
    : FList: PPointerList;
    : FCount: Integer;
    : FCapacity: Integer;
    : ...
    :
    : [/code]
    :
    : That MaxListSize constant is 134217728, a Pointer is stored on 4 bytes
    : so a TPointerList is stored on 134217728 x 4 = 536870912 bytes????
    : That is 512 MB of memory!!! PPointerList in change only eats 4 bytes.
    : Or how is this? Can anyone explain?
    :
    :
    :
    :
    :
    The memory of a TList is determined by its Capacity property. The pointerlist is reallocated every time the Capacity changes.
Sign In or Register to comment.