IIRC An array = nil is precisely the same as an array where 
Length(array) = 0

Since you should always check the length of the array when accessing it,
setting it to nil is usually a safe bet. 

Stephen 

> -----Original Message-----
> From: Myles Penlington [mailto:[EMAIL PROTECTED] 
> Sent: Monday, 25 August 2003 9:52 a.m.
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Access Violations
> 
> 
> J,
> Hope it does not break your existing code, if relies on the 
> array to always exist ... Myles.
> 
> -----Original Message-----
> From: vss [mailto:[EMAIL PROTECTED]
> Sent: Monday, 25 August 2003 09:46
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Access Violations
> 
> 
> Myles
> I am going to try myArray=Nil and see how that goes.
> This might be a better option?
> 
> Jeremy
> 
> -----Original Message-----
> From: Myles Penlington <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Date: Mon, 25 Aug 2003 09:34:44 +1200
> Subject: RE: [DUG]:  Access Violations
> 
> > J,
> > Had to check the Finalize code for my own sanity. So it is safe to 
> > call Finalize twice on the same string array.
> >  
> > I think you know this, but calling Finalize does not deallocate the 
> > array, just deallocates all the strings it references. So I don't 
> > really see how it
> > solves your real problem - it may do as a side effect. In 
> my opinion,
> > it
> > just appears to fix the problem. I may be crossing wires 
> here, looking
> > at
> > part of the original post ( or is this just fixing one of 
> the issues -
> > in
> > which case the finalize would be sufficient, may have got 
> too far off
> > track)
> > 
> > I have never yet had to call Finalize directly.
> > 
> > Myles.
> > 
> > -----Original Message-----
> > From: vss [mailto:[EMAIL PROTECTED]
> > Sent: Monday, 25 August 2003 09:06
> > To: Multiple recipients of list delphi
> > Subject: RE: [DUG]: Access Violations
> > 
> > 
> > Well, with out it, the memory usage increased...I am runing 
> some tool,
> > forget what its called, and it tells you how much mem its using.
> > Also from the Help :-
> > 
> > Finalize simply sets all long strings to empty and all variants and
> > interfaces to Unassigned, thus properly releasing any 
> memory that was 
> > referenced by the long strings and variants.
> > 
> > The Dyn. Array is just arrays of strings sho this should be ok.
> > 
> > Jeremy
> > 
> > -----Original Message-----
> > From: Myles Penlington <[EMAIL PROTECTED]>
> > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > Date: Mon, 25 Aug 2003 08:23:05 +1200
> > Subject: RE: [DUG]:  Access Violations
> > 
> > > Huh?
> > > Set array to zero? You mean length? The normal method is to assign
> > nil
> > > to
> > > the array variable.
> > > Have never investigated the effect of using Finalize twice ... If 
> > > finalize actually sets the fields to nil/binary zero 
> would be okay.
> > > Hope it's not hiding the real problem or it may be pointing to the
> > > actual
> > > source of the real problem - invalid cast on dynamic 
> array reference?
> > > Myles.
> > > 
> > > -----Original Message-----
> > > From: Jeremy Coulter [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, 25 August 2003 07:56
> > > To: Multiple recipients of list delphi
> > > Subject: RE: [DUG]: Access Violations
> > > 
> > > 
> > > Hmm...well, if I have to set the array to zero, then I 
> might as well 
> > > use Finalize.
> > > Either wau, by usig Finalize, the problems have gone 
> away, so it must
> > > hae helped.
> > > 
> > > Jeremy
> > > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> > On
> > > Behalf Of Myles Penlington
> > > Sent: Friday, 22 August 2003 20:22
> > > To: Multiple recipients of list delphi
> > > Subject: RE: [DUG]: Access Violations
> > > 
> > > 
> > > Should not have to use finalize - it is done automatically for
> > dynamic
> > > arrays, once there reference count drops to zero. Myles
> > > 
> > > -----Original Message-----
> > > From: vss [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, 21 August 2003 10:16
> > > To: Multiple recipients of list delphi
> > > Subject: RE: [DUG]: Access Violations
> > > 
> > > 
> > > Just going thru the code, and the guy who wrote some of the core
> > > functions used Dynamic arrays in quite a few places, BUT 
> here never
> > > uses
> > > 
> > > Finalize() when he has finished with the array ! infact, it just
> > stays
> > > allocated !
> > > Some of these functions are call quite a lot of times too !
> > > 
> > > Looks like a start !
> > > 
> > > Jeremy
> > > 
> > > -----Original Message-----
> > > From: Myles Penlington <[EMAIL PROTECTED]>
> > > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > > Date: Thu, 21 Aug 2003 09:36:59 +1200
> > > Subject: RE: [DUG]:  Access Violations
> > > 
> > > > Your AV trace stuff is not very good - the call stack does not 
> > > > make sense.
> > > > 
> > > > However, the address given would appear to be a nil object
> > reference
> > > > (or an
> > > > array?) - ie 0 + objectfieldoffset (Of a rather large object) ie
> > 267
> > > > bytes from the object base.
> > > > 
> > > > We have had the SQL general network error problem 
> ($80000045 from
> > > > memory), and the root cause was corrupted memory in our 
> application
> > -
> > > > invalid variants and WideStrings - note this is important. Ie it
> > was
> > > > not a problem
> > > > with the SQL box, but rather issues in our code. And the app did
> > not
> > > > fall
> > > > apart straight away. ie could take several minutes 
> before it gave
> > the
> > > > error
> > > > in the end.
> > > > 
> > > > We ended up using some tools like BoundsChecker etc to test the
> > app.
> > > > But even with these it was very had to find. These in essence 
> > > > ruled out all the basic stuff, but did not locate the 
> exact error 
> > > > - just narrowed
> > down
> > > > the
> > > > area.
> > > > 
> > > > Myles.
> > > > 
> > > > -----Original Message-----
> > > > From: vss [mailto:[EMAIL PROTECTED]
> > > > Sent: Wednesday, 20 August 2003 16:05
> > > > To: Multiple recipients of list delphi
> > > > Subject: [DUG]: Access Violations
> > > > 
> > > > 
> > > > Hi All.
> > > > An app. I wrote every now and then gets a GPF.
> > > > I am almost certain that the problem is related to or MSSQL box
> > > > because every now and again we get general network 
> errors, but its
> > > not
> > > 
> > > > very consistant, and our engineers dont seem to believe 
> us ! I run
> > > > "eXpress Application Manager" AV stuff which gives me some res. 
> > > > information, BUT I think the error below is really being caused 
> > > > somewhere else or as a result of something else like 
> the SQL box 
> > > > problem above.
> > > > BUT can someone look at it and tell me if it is not 
> something else?
> > > > The Other reason I am sceptical is that 2 users were in 
> 2 different
> > > > parts of the app, and they both got the same error at the same 
> > > > time...well thats the story "I" got :-)
> > > > 
> > > > Jeremy
> > > > 
> > > > # 20/08/2003 09:31:12 [ EXCEPT ] Type         : 
> EAccessViolation ( 
> > > > EExternal )
> > > >                                  Unit         : Controls
> > > >                                  Line         : 10478
> > > >                                  Class        : <N/A>
> > > >                                  Function     : InitIMM32
> > > >                                  Address      : 0x00482581
> > > >                                  Sender Class : <N/A>
> > > >                                  Sender Name  : <N/A>
> > > >                                  Message      : Access 
> violation at
> > > > address 00482581 in module 'ComCare.exe'. Read of 
> address 0000010B
> > > >                                  Call Stack   : 
> DBConsts::DateUtils
> > > >                                                 
> > > > SqlTimSt::TSQLTimeStampData.DoSubtract
> > > >                                                 
> > > > SqlTimSt::TSQLTimeStampData.Compare
> > > >                                                 
> > > > SqlTimSt::TSQLTimeStampData.DoAdd
> > > >                                                 
> > > > IniFiles::TCustomIniFile.ReadInteger
> > > >                                                 
> > > > Forms::TApplication.ActivateHint
> > > >                                                 
> > > > MultiMon::_GetSystemMetrics
> > > >                                                 System::TextOut
> > > >                                                 
> > > > System::@HandleAutoException
> > > >                                                
> > > > System::@InitializeArray
> > > >                                                 
> > > > SysUtils::ValidateTimeStamp
> > > >                                                 
> SysUtils::FormatBuf
> > > >                                                 System::TextOut
> > > >                                                 
> System::ToLongPath
> > > >                                                 
> System::ToLongPath
> > > >                                                 ImgList::Forms
> > > >                                                
> > > Forms::HintMouseThread
> > > >                                                 
> > > > Forms::TScreen.GetMetricSettings
> > > >                                                 ImgList::Forms
> > > >                                                 
> > > > StdCtrls::TListBoxStrings.Get
> > > >                                                 
> > > > Forms::TApplication.ActivateHint
> > > >                                                 
> > > > MultiMon::_GetSystemMetrics
> > > >                                                 System::TextOut
> > > >                                                 System::@Assign
> > > >                                                 
> > > > System::@WStrFromPWChar
> > > >                                                 
> > > > F_XAM_Log::TfmXAMLog.FormCreate
> > > >                                                 
> > > > IniFiles::F_XAM_Log
> > > >                                                
> > <Unknown>::<Unknown>
> > > >                                                 
> > > > Variants::VarOpRare
> > > >                                                
> > <Unknown>::<Unknown>
> > > > 
> > > >
> > >
> > 
> ----------------------------------------------------------------------
> > > > -
> > > > ----
> > > >     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/
> > 
> >
> ----------------------------------------------------------------------
> -
> > ----
> >     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/

------------------------------------------------------------------------
---
    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