Memory leak detection tools

2019-01-01 15:43发布

Does Apple's Xcode development environment provide any tools for memory leak detection?

I am especially interested in tools that apply to the iPhone SDK. Currently my favourite platform for hobby programming projects

Documentations/tutorials for said tools would be very helpful.

11条回答
几人难应
2楼-- · 2019-01-01 16:11

Does Apple's Xcode development environment provide any tools for memory leak detection?

I am especially interested in tools that apply to the iPhone SDK.

Yes. Apple calls them "Instruments" (there's more than just memory tools).

See Apple's Introduction to Instruments User Guide. In particular, see Locating Memory Issues in Your App. It provides examples of how to use the memory-oriented trace templates.

查看更多
孤独寂梦人
3楼-- · 2019-01-01 16:12

ObjectAlloc and MallocDebug should both be of help to you. If you installed the entire SDK, they will be found in Developer->Applications->Performance Tools.

Their names give you a pretty good clue as to their functions, OA, tracks the objects create and MA is a general memory leak tool.

I haven't tried them with iPhone development yet, but I have to believe that they would work there as well.

Assuming you have registered for ADC iPhone developer site, here the link to follow:Instruments User Guide

查看更多
美炸的是我
4楼-- · 2019-01-01 16:14

Made a sum up of the main memory leak tools: iphone-essential-performance-tools-list

查看更多
无色无味的生活
5楼-- · 2019-01-01 16:16

There is one specifically called Leaks and like a previous poster said, the easiest way to run it is straight from Xcode:

run -> Start with Performance Tool -> Leaks

It seems very good at detecting memory leaks, and was easy for a Non-C Head like me to figure out.

查看更多
君临天下
6楼-- · 2019-01-01 16:17

When using rustyshelf's solution make sure you test on the iPhone and not on the simulator. Memory usage is dramatically different.

查看更多
公子世无双
7楼-- · 2019-01-01 16:18

Select Profile from the Product menu in Xcode 6 to launch Apple's Instruments tool. (The application is located inside the Xcode application's package contents: /Applications/Xcode.app/Contents/Applications/)

A commercial alternative is OmniObjectMeter. (Discontinued by The Omni Group)

查看更多
登录 后发表回答