Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Pulkit

macrumors newbie
Original poster
Aug 27, 2008
25
0
Friends,

I need a tool which can help me to find memory leaks, bad memory allocations, allocation and deallocations problems in my application.

Like MemCheck we have on Windows.

Thanks,
Pulkit
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
As per usual it's all covered in the documentation (and clearly mentioned and demonstrated in the getting started videos that all developers should have watched).

Instruments
 

ace2600

macrumors member
Mar 16, 2008
71
0
Austin, Texas
I was/am planning on making a full post about this because I find it incredibly useful: Clang Static Analyzer.

It's a tool utilizing LLVM/Clang which automatically finds memory leaks and other possible bugs with your code. It generates a nice HTML report for where the error occurs and how it got there.

I have found sticking to a coding standard is the single best way to prevent memory leaks. For example, always autorelease or always do the init, set, release jig, etc. However, tools like the static analyzer may find bugs you were unaware of.

website:
http://clang.llvm.org/StaticAnalysis.html

quick tutorial on setting up for iPhone development:
http://www.rhonabwy.com/wp/2008/10/...clang-static-analyzer-with-an-iphone-project/
 

Pulkit

macrumors newbie
Original poster
Aug 27, 2008
25
0
I was/am planning on making a full post about this because I find it incredibly useful: Clang Static Analyzer.

It's a tool utilizing LLVM/Clang which automatically finds memory leaks and other possible bugs with your code. It generates a nice HTML report for where the error occurs and how it got there.

I have found sticking to a coding standard is the single best way to prevent memory leaks. For example, always autorelease or always do the init, set, release jig, etc. However, tools like the static analyzer may find bugs you were unaware of.

website:
http://clang.llvm.org/StaticAnalysis.html

quick tutorial on setting up for iPhone development:
http://www.rhonabwy.com/wp/2008/10/...clang-static-analyzer-with-an-iphone-project/

I really want to use this tool. Can you tell me detail steps to install this on my machine. I tried the steps mentioned "Seatle Bus" but that didn't work.

I have downloaded the .taz.bz file from the Clang website now can you tell me what should I do from here?

Please help!
 

ace2600

macrumors member
Mar 16, 2008
71
0
Austin, Texas
Can you tell me detail steps to install this on my machine.
Sure.
  1. Go to http://clang.llvm.org/StaticAnalysis.html
  2. Download checker-xxx.tar.bz2 in the bottom right (is currently checker-113.tar.bz2 for the October 20th build)
  3. Extract to some directory (I chose ~/Development/tools/clang)
  4. Open your project in XCode and set settings to Simulator and Debug
  5. Build and Run (this step may be optional)
  6. Quit XCode
  7. In your terminal, cd to your project directory
  8. rm -rf ./build (this step may be optional)
  9. rm -rf /tmp/scan* (this is where the HTML reports are stored, this step may be optional too)
  10. run "/location/of/unzipped/file/scan-build --view xcodebuild". For example, I run "~/Development/tools/clang/scan-build --view xcodebuild". --view tells the scan-build to automatically bring up the HTML report in the browser.
 

MikeBrWade

macrumors member
Oct 21, 2008
58
0
Attach some instruments in the IDE the leak detector is "okay", but if you know how to read a stack and trace signals the object allocated one is the best, I tend to keep that one and the utilization ones open during my "testing" phases of development.

Be wary of leaks they will get you if you code sloppy or even because of some of apple's own mistakes *cough*UIWebView*cough*
 

Pulkit

macrumors newbie
Original poster
Aug 27, 2008
25
0
Sure.
  1. Go to http://clang.llvm.org/StaticAnalysis.html
  2. Download checker-xxx.tar.bz2 in the bottom right (is currently checker-113.tar.bz2 for the October 20th build)
  3. Extract to some directory (I chose ~/Development/tools/clang)
  4. Open your project in XCode and set settings to Simulator and Debug
  5. Build and Run (this step may be optional)
  6. Quit XCode
  7. In your terminal, cd to your project directory
  8. rm -rf ./build (this step may be optional)
  9. rm -rf /tmp/scan* (this is where the HTML reports are stored, this step may be optional too)
  10. run "/location/of/unzipped/file/scan-build --view xcodebuild". For example, I run "~/Development/tools/clang/scan-build --view xcodebuild". --view tells the scan-build to automatically bring up the HTML report in the browser.

I follow these steps but I got a Build Failed message. Reason it gave to me is as follows:
Reason : gcc-4.0: installation problem, cannot exec "/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1": No such file or directory.

Any Ideas?
 

ace2600

macrumors member
Mar 16, 2008
71
0
Austin, Texas
I had that until I switched the XCode project to Simulator instead of Device. This error is because the analyzer does not support ARM binaries.

Also, in Step 5, instead of Build and Run, do a Clean on the target and do NOT Build and Run.
 

Pulkit

macrumors newbie
Original poster
Aug 27, 2008
25
0
I had that until I switched the XCode project to Simulator instead of Device. This error is because the analyzer does not support ARM binaries.

Also, in Step 5, instead of Build and Run, do a Clean on the target and do NOT Build and Run.

And why it is giving me following error:

"CodeSign error: no provisioning profile found with UDID...."

Any ideas?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.