by fzammetti » Feb 5, 2003 @ 5:55am
No, you won't get an error if you write past the bounds of an array. Unfortunately in that respect, this isn't Java!
I know this from recent experience... My current project I had an array that gets cleared at the beginning of various screens in the game. Well, I was off by 1 when clearing the array, and what would happen is that if I compiled the program as a debug build, no problem manifested itself. However, when I switched to a release build, a completely unrelated screen was giving me problems.
I know that release builds by default turn off array bounds checking, and my assumption is that those checks, which would be present in a debug build usually, just stop the overwrite from happening, but still give no error. I could be wrong about that.
It was either that, or it must have been laying the allocated array memory out differently in release vs. debug and the off-by-one loop was only causing a problem when it was layed out a certain way, i.e., how it was in the release build (spent the better part of a day walking through code line-by-line banging my head against the desk before I figured that one out).
So, ignoring my pointless and somewhat off-topic babbling...
Could it be a debug vs. release build issue?
And in either case, you won't get any error if you overwrite bounds arrays. C just isn't that nice!
Also, your thought that if might not be the file access but the array maniulations should be easy to test: simply comment out the code that writes to a file, but leave all the array stuff intact. If it's the array code, you should still see your freezes.
A memory-mapped file by the way is basically just a file that you treat as a chunk of memory. Not sure that would really benefit you much here, but that's a very simplistic explanation anyway.
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"