diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 3a08520e1..7f4a7e1a7 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -2138,8 +2138,18 @@ void VG_(arena_free) ( ArenaId aid, void* ptr ) carefully chosen junk :-), in that: (1) 0xDDDDDDDD is an invalid and non-word-aligned address on most systems, and (2) 0xDD is a value which is unlikely to be generated by the new compressed - Vbits representation for memcheck. */ - if (aid != VG_AR_CLIENT) + Vbits representation for memcheck. + + CodSpeed: this is a pure debugging aid (it only makes use-after-free + bugs *in V itself* more likely to be noticed), but it is expensive: + it writes every byte of every block V frees, which on a debuginfo + heavy run amounts to hundreds of MB of stores plus the page faults + needed to first-touch the parts of a block that were never used. + It is therefore only done at the sanity levels reserved for + expensive self-checks (--sanity-level=3 and above); the matching + fill on the malloc side is disabled by default for the same + reason (see VG_(arena_malloc)). */ + if (aid != VG_AR_CLIENT && UNLIKELY(VG_(clo_sanity_level) >= 3)) VG_(memset)(ptr, 0xDD, (SizeT)b_pszB); if (! sb->unsplittable) {