int* foo = new int[10];
foo = NULL;
sleep(60);
Instrument is not finding any leak in above code, how do I use Instrument tool to find C or C++ code leaks. I have stack overflowed most of the explanation is based on objective C codes…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The issue is that compiler will optimize out the call to
newin the following code fragment:as it’s smart enough to know that it’s not being used. If you add code to use
foothen compiler won’t do this and you should see the leak you are expecting: