Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Wayne K. Werner" Newsgroups: scea.yaroze.programming.codewarrior Subject: Re: System memory Date: 11 Aug 1997 22:39:27 GMT Organization: WermX Software Lines: 31 Message-ID: <01bca6a7$43e59580$adbf43ce@wkwerner> References: <01bc957d$ffb78880$9fbf43ce@wkwerner> <33d63ee2.2608036@news.scea.sony.com> <01bca2b9$a16f32c0$69bf43ce@wkwerner> <33E9982D.54A636C9@micronetics.com> <5snuct$dp61@scea> NNTP-Posting-Host: port73.con2.com X-Newsreader: Microsoft Internet News 4.70.1161 Joel Sumner suggested using a "wall". Walls are often used in heap allocations also, to try to run down overflows in heap arrays, for instance. The low overhead does make it a good candidate for constant inclusion, while the big guns can be dragged out when needed. That is one reason I suggested a #define to remove the stack checking from your code. This allows you to take the hit on size and speed only when you turn stack checking on. A couple of caveats re walls... They fail if, by some slim chance, the data that overflows is the same as the data in the wall. A rare occurance indeed. This can be minimized by not using 0, perhaps the most common number to be writen to memory. (I have often seen the value 0x0BADBEEF used, as it is very easy to see in a hex dump.) Also, when a wall gets munged, the culprit could be elswhere than where you are watching. For instance, you might have a runaway pointer and have trashed the wall that way, not through the stack pointer at all. Another option is what is generally refered to as a watchpoint. Watchpoints are like breakpoints, however, instead of stopping execution when a specific line of code is reached, execution is stopped when a particular memory address is writen. Watchpoints put you right to the line of code causing the memory write in question. I am unaware of whether watchpoints are supported by CW. Unless they are supported by the hardware, as well as the debugger, they cause MAJOR hits to the speed of the code under the debugger. Often that is acceptable, especialy when tracking down a nasty memory corruption problem. -- Wayne K. Werner wkwerner@con2.com