• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Facing an issue with leaks utility in mac in usage with the xcode project
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Facing an issue with leaks utility in mac in usage with the xcode project


  • Subject: Facing an issue with leaks utility in mac in usage with the xcode project
  • From: mac adobe <email@hidden>
  • Date: Thu, 30 Apr 2009 20:59:53 +0530

Hi all,

 

I am on lepord 10.5.7 . The following issue was also seen in 10.5.5 .

 

I am facing an issue with leaks utility in mac and would like your comments on the same .

 

I have introduced  leaks explicitly in my xcode test case program through

 

char *p=(char*) malloc(1000*sizeof(char));

p=NULL;

 

As per the man pages of the leaks utility  , it catches all leaked memory – memory that has been allocated but has been lost and cannot be freed . As in the above said case 1000 characters have been allocated and the only pointer to the said 1000 characters has been lost by p=NULL , I expected leaks to tell me this as a leak . However it did not .

 

Do we need to set any variable (environment ) etc to make leaks catch this error ?

I had set the environment variable  by export MallocStackLogging=1 which is used for displaying stack trace AFTER it identifies a leak  .

 

Has anyone else faced similar issues in the past or am I doing it the wrong way . Kindly comment .

 

 

Also I see that

 

1)      Many a times leaks utility gives strange behavior , identifying leaks during a run  and in subsequent runs of the same test program  , not identifying leaks at all .

2)      Identifying leaks only in function calls and not in main program .

3)      Not identifying leaks at all in those cases where an external dll have been used .

 

Let me give you the sample code which I used test using leaks utility on mac .

 

Since it was not giving leaks with 1000 I increased it several times but still no help .

 

#include <iostream>

 

void callme()

{

     char *p=(char *) malloc(1024*1024*sizeof(char));

}

 

int main (int argc, char * const argv[]) {

     int i ;

     std::cin >>i;

     std::cout << "Hello, World!\n";

     callme();

     char *c =(char *) malloc(5000*sizeof(char));

     c=(char *)malloc(5000*sizeof(char));

     c=NULL;

     std::cin >>i;

     return 0;

}

 

 

1)      This code fragment was compiled and then run . and attached to instrument’s leaks utility (during call of first scanf I attached the process with leaks utility) . It is clear that callme() will lead to memory leak . However the leaks utility identified it only once and during reruns of the same test program it failed to identify this as a leak .

 

2)      During cases when leaks utility did identified it as a leak , it failed to identify leaks in main

 

                                char *c =(char *) malloc(5000*sizeof(char));

                                  c=(char *)malloc(5000*sizeof(char));

                                c=NULL;

 

   Note that since c is pointing to memory of  character  5000 and later points to another 5000 different memory , we should get a leak in main also . However leak utility   

   failed to identify this as a leak .

 

        Please note that we did set export MallocStackLogging=1    before running the program in the same terminal window

 

 

 

Has anyone else faced similar issues in the past or am I doing it the wrong way . Kindly comment .

 

 

 

 

Thanks and Regards

Manish

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Facing an issue with leaks utility in mac in usage with the xcode project
      • From: Bill Bumgarner <email@hidden>
    • Re: Facing an issue with leaks utility in mac in usage with the xcode project
      • From: Fritz Anderson <email@hidden>
    • Re: Facing an issue with leaks utility in mac in usage with the xcode project
      • From: Luis Vitorio Cargnini <email@hidden>
  • Prev by Date: Re: Bug in Debugger?
  • Next by Date: Re: Bug in Debugger?
  • Previous by thread: Re: Bug in Debugger?
  • Next by thread: Re: Facing an issue with leaks utility in mac in usage with the xcode project
  • Index(es):
    • Date
    • Thread