MALLOC_PERTURB_: everyone should set this envvar

Jim Meyering jim at meyering.net
Mon Jun 4 15:36:55 UTC 2012


John Reiser wrote:
>>     # http://udrepper.livejournal.com/11429.html
>>     export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
>
> For supportability (and to help remind you to turn it off before
> performance tests), then also consider adding a line such as:
>      echo 1>&2 MALLOC_PERTURB_=$MALLOC_PERTURB_  " # $HOME/.bash_profile"

Good idea.  Or have a weekly cron job send clue-bat mail to
yourself reminding you that you do have this envvar set.

For the first year or so during which I had this enabled,
when I'd hit a memory-related problem, I didn't immediately think,
"Oh! that may be because I've enabled MALLOC_PERTURB_", so the
above might well help, initially.

If you do add something like that, be sure to use a guard so
that it is printed only for interactive sessions, e.g.,

    test -n "$PS1" && echo 1>&2 MALLOC_PERTURB_=$MALLOC_PERTURB_

Once you've been graced with enough MALLOC_PERTURB_-induced
failures, you get used to it, always remember to include it in
bug reports,... then you can turn that off ;-)


More information about the devel mailing list