A Threadvar means that the variable exists and has a different value for
every thread. Ie you have to initialise or Create the String list for every
thread that references the thread variable. Not very nice really. Also note
that threadvars are quite slow to be accessed.

If you are using TThread, you are better off creating the string list for
each TThread object and passing this into your procedures/methods.

Myles.


-----Original Message-----
From: David McNeill [mailto:[EMAIL PROTECTED]
Sent: Thursday, 11 September 2003 13:30
To: Multiple recipients of list delphi
Subject: RE: [DUG]: TStringList or Memory error.


Thanks for the pointers...

1) Are you using interfaces? If so, check that the referenced object
hasn't
been relased.

.. No interfaces


2) Have you got your code that references the stringlist wrapped up in a
critical section?

.. Shouldn't need to because it's threadvar - the thread can write to
the string list any time it feels like it, it has it's own instance of
the stringlist. 
Is my assumption correct?


3) Are you trying to access an item in the list that doesn't exist (eg,
MyList[4] when MyList only contains 4 items - remember that TStringList
is 0
based)?

.. Only using .add    Generally I then use .text then .clear  , so no,
not an indexing issue.







These are probably all obvious ones you have already checked, but you
didn't
say what you had checked or not.

Phil.
----- Original Message ----- 
From: "David McNeill" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, September 11, 2003 11:56 AM
Subject: [DUG]: TStringList or Memory error.


> This is a nasty one I can't get to the bottom of, so any clues or tips
> would be appreciated.
>
> Fundamental problem: Access Violation on accessing a stringlist.
>
> Situation: Database update process iterates 700+ times, doing the same
> thing, before tipping over.
>
> It's like the tstringlist "disappears" for some unknown reason.
>
> I use the same method in thousands of other lines, and never fails.
>
> Breaks on two servers at the customers place, but not on my dev
server.
>
>
> Multi-threaded tray app, using Indy http server.
>
>
> Snips:
>
>
> Main.pas
> threadvar
>   tlResult:TStringlist;
>
> Main.pas
> Procedure TimerExecute;
> Tlresult:=tstringlist.create;
>
> DoDatabaseProcessing;
>
>
> Database.pas
> Procedure DoDatabaseProcessing;
> While not database.eof do begin
>   .. hundreds of lines
>   tlresult.add('Ok: Processed item '+IntToStr(RecordNo));  // access
> violation
> end;
>
>
>
>
> I tried descending tstringlist and putting in a log on
BeforeDestruction
> , but it does not appear the stringlist is explicitly being destroyed.
>
> It is more like something else is clobbering it's memory, and it is
> "disappearing" at some point.
>
> Any help appreciated.
>
>
> David McNeill
> McPond eCommerce Software
> [EMAIL PROTECTED]
> Buchanan Road
> Franklin
> New Zealand
> Phone 09 292 7212
>
>
>
>
>
>
>
>
>
>
------------------------------------------------------------------------
--
-
>     New Zealand Delphi Users group - Delphi List -
[EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>


------------------------------------------------------------------------
---
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to