>My array of 36 doubles is initialized at program start by writing a 
>valid value to each and every one of the 52 cells (Note that I wrote to 
>52 cells, but the array was only 36 in size!)

The memory you are accessing is almost certainly already being used by
your program for other variables (typically whatever you declared
immediately after it, depending on how you declared it), so you are
over-writing some of your own variables (or objects).

In previous versions of your software, you were most likely initialising
some other variables that didn't really matter (perhaps more data that
you actually initialised AFTER the array). Now you have added, removed
or changed the order such that what you are overwriting during
initialisation is something that is needed to tidy up when the application
closes. This might be the header information for an object that needs to
be released, perhaps your main form.

This means that as far as the OS is concerned there is nothing wrong
- you are accessing memory that is allocated to you.
As far as the code generator is concerned there is also nothing wrong
- because you had range checking turned off, which means that you have
taken responsibility for checking that your accesses are always in range.

In neither case did you access an "illegal memory location", so there would
be no error at that time. What you did do, however was corrupt some
information that is only needed at application termination, hence that
is when you get an error.

You can, of course, turn range checking on for a test build to catch this
sort of thing, and then turn it off for release (if you trust your ability
to test thoroughly), but have you actually measured whether range checking
makes a real difference to your execution time?

Most software spends a lot of time waiting for the user (the slowest
peripheral), and so it becomes a case of "hurry up and wait"

If you imagine a system where the generated code (or OS) is continually
checking that your code hasn't corrupted anything it will need later (at
the level of granularity needed here, rather than by memory page), than
the performance would be much worse than what you get by turning range
checking on (and it would be outside your control).

Regards,
Ken


_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://www.elists.org/mailman/listinfo/delphi

Reply via email to