www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Unused memory filling

reply bearophile <bearophileHUGS lycos.com> writes:
In two places I have read about 'shredding your trash', that is filling the
memory that's supposed to be free and not used any more with a constant known
value different from zero, to allow bugs in pointer usage to surface faster. So
is it a good idea for the D GC to perform such overwriting of the memory it
frees, when the program is compiled in debug mode?

Bye,
bearophile
Dec 13 2010
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Mon, 13 Dec 2010 14:27:02 +0200, bearophile <bearophileHUGS lycos.com>  
wrote:

 In two places I have read about 'shredding your trash', that is filling  
 the memory that's supposed to be free and not used any more with a  
 constant known value different from zero, to allow bugs in pointer usage  
 to surface faster. So is it a good idea for the D GC to perform such  
 overwriting of the memory it frees, when the program is compiled in  
 debug mode?

 Bye,
 bearophile
See the MEMSTOMP debug option in the current GC implementation. There are also a few other useful options, such as SENTINEL. Shameless plug: Diamond ( https://github.com/CyberShadow/Diamond ) also has a MEMSTOMP option, which can be useful if you have a single-threaded D1 program and don't want to rebuild Phobos. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Dec 13 2010