I am writing a scientific code in C++. I had activated Guard Dmalloc under "edit scheme" some while ago, and it had been silent.
I became suspicious, and wrote code that deliberately wrote to memory that is outside a malloced allocation, and I got no warning.
The online blogs etc have not been helpful, and are confusing, appearing to need me to set environment variables in the terminal window!
After trying all sorts of "coding crimes" to trigger Guard dmalloc, I suddenly get the message
GuardMalloc[KLiNG-62222]: Attempting excessively large memory allocation: 188800000 bytes
GuardMalloc[KLiNG-62222]: If you really wanted to allocate so much memory, launch your executable with the environment variable MALLOC_PERMIT_INSANE_REQUESTS set to any value to circumvent this check.
GuardMalloc[KLiNG-62222]: Explicitly trapping into debugger!!!
It is true: I am trying to allocate ~200 MB of memory. I have 64 GB available, so this is no crime. My questions are these;
(1) Where, within XCODE, do I set MALLOC_PERMIT_INSANE_REQUESTS? I tried going to the terminal window and entering set env MALLOC_PERMIT_INSANE_REQUESTS = 1 restarting XCODE, but no joy.
(2) Why is Guard Dmalloc only now starting to give messages? The "insane memory request" has been there for 3 years and not a squeak from Guard Dmalloc until now!
Thinking back, what I did do that was different is that I held down the option key while clicking the "run" arrow, and then clicked the "Run" button in the dialog box that appeared. That dialog box is identical to the "Edit Scheme" dialog box that I had used years ago to enable Guard Dmalloc. However, the "option->run" version has "Run" to close it; the "Edit Scheme" version has "Close".
I think that when I did "option->run" XCODE may have only then activated Guard Dmalloc. I am not sure, though.
Guard Dmalloc is now activated and works for me now when I click the "Run" arrow directly (no "option->run" needed anymore). I suppose that is good news. Now I have to find out where to set MALLOC_PERMIT_INSANE_REQUESTS = 1, plus other environment variables.
Many thanks in advance for any help.