Actually enable memory-checking code when in debug mode

(it was checking the wrong flag, so probably never enabled)