Board index » delphi » Stringlist question...

Stringlist question...

I have several temp stringlists I use in my program, some of which
have several thousand entries.

For some reason when I want to clear the temp workspace stringlists a
.clear works fine, but the program seems to run a lot slower the
second time through, than the first. If I shutdown and restart it,
it's back to normal speed again.
Is there any reason for this, or should I .free and .create them to
wipe them completely?

Dodgy.

 

Re:Stringlist question...


Only free'ing and recreating the stringlist won't work. The problem is the
heap that will become more and more fragmented. The only way to solve that
problem is by freeing ALL dynamically allocated data and reallocate it
(which is almost the same as restarting the application).

ps. You can speedup the processes of adding items to a stringlist if you set
the Capacity property to a rough estimate of the final number of items in
the list.

"Dodgy" <Do...@earth.planet.universe> schreef in bericht
news:pdjo5tsbk8h7a2ir7fcglj0toplegfqceu@4ax.com...

Quote
> I have several temp stringlists I use in my program, some of which
> have several thousand entries.

> For some reason when I want to clear the temp workspace stringlists a
> .clear works fine, but the program seems to run a lot slower the
> second time through, than the first. If I shutdown and restart it,
> it's back to normal speed again.
> Is there any reason for this, or should I .free and .create them to
> wipe them completely?

> Dodgy.

Re:Stringlist question...


Thanks, I'll give the capacity a try. I assume that makes Delphi
reserve a non-fragmented block of heap purely for that stringlist up
to the size specified, and I can exceed it, but then it will probably
be fragmented.

Dodgy.

On Wed, 10 Jan 2001 13:24:29 +0100, "M.H. Avegaart"
<avegaartNOS...@mccomm.nl> waffled on about something:

Quote
>Only free'ing and recreating the stringlist won't work. The problem is the
>heap that will become more and more fragmented. The only way to solve that
>problem is by freeing ALL dynamically allocated data and reallocate it
>(which is almost the same as restarting the application).

>ps. You can speedup the processes of adding items to a stringlist if you set
>the Capacity property to a rough estimate of the final number of items in
>the list.

>"Dodgy" <Do...@earth.planet.universe> schreef in bericht
>news:pdjo5tsbk8h7a2ir7fcglj0toplegfqceu@4ax.com...
>> I have several temp stringlists I use in my program, some of which
>> have several thousand entries.

>> For some reason when I want to clear the temp workspace stringlists a
>> .clear works fine, but the program seems to run a lot slower the
>> second time through, than the first. If I shutdown and restart it,
>> it's back to normal speed again.
>> Is there any reason for this, or should I .free and .create them to
>> wipe them completely?

>> Dodgy.

Re:Stringlist question...


No, the list will not be fragmented, just reallocated (but the heap will be
fragment).

"Dodgy" <Do...@earth.planet.universe> schreef in bericht
news:fb1p5tsthaedidj59cqo6br8q4vqs2dh6u@4ax.com...

Quote
> Thanks, I'll give the capacity a try. I assume that makes Delphi
> reserve a non-fragmented block of heap purely for that stringlist up
> to the size specified, and I can exceed it, but then it will probably
> be fragmented.

> Dodgy.

> On Wed, 10 Jan 2001 13:24:29 +0100, "M.H. Avegaart"
> <avegaartNOS...@mccomm.nl> waffled on about something:

> >Only free'ing and recreating the stringlist won't work. The problem is
the
> >heap that will become more and more fragmented. The only way to solve
that
> >problem is by freeing ALL dynamically allocated data and reallocate it
> >(which is almost the same as restarting the application).

> >ps. You can speedup the processes of adding items to a stringlist if you
set
> >the Capacity property to a rough estimate of the final number of items in
> >the list.

> >"Dodgy" <Do...@earth.planet.universe> schreef in bericht
> >news:pdjo5tsbk8h7a2ir7fcglj0toplegfqceu@4ax.com...
> >> I have several temp stringlists I use in my program, some of which
> >> have several thousand entries.

> >> For some reason when I want to clear the temp workspace stringlists a
> >> .clear works fine, but the program seems to run a lot slower the
> >> second time through, than the first. If I shutdown and restart it,
> >> it's back to normal speed again.
> >> Is there any reason for this, or should I .free and .create them to
> >> wipe them completely?

> >> Dodgy.

Other Threads