Phát triển ứng dụng cho iPhone và iPad - part 39

Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 39', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Instruments 349 This method simply creates an NSMutableString object appends four strings to it and logs the string to the console. Take a second and see if you can discover the memory leak on your own. The leak occurs because you allocated the NSMutableString object theString using a call to alloc but you never released this object. After this method ends the pointer to the string object will be gone. This memory is now unrecoverable resulting in a memory leak. Build and run the application. When the simulator comes up click on the Go button. You should see this text in the console theString is This is a string. Analyzing a Memory Leak in Instruments Now that you have the sample application coded and ready to go it s time to find the memory leak in the application using Instruments. In Xcode select Run O Run with Performance Tool O Leaks from the menu bar. Once the application starts in the simulator you will see a dark gray triangle at the top of the Track pane start to move from left to right. This indicates that Instruments is recording data from the running application. The Leaks instrument is configured to auto-detect leaks in your application every ten seconds. You can force manual detection of leaks at any time by clicking on the Check for Leaks Now button that appears in the left side of the Detail pane when you have the Leaks instrument selected in the Instruments pane. After the application starts and Instruments is running click the Go button in the iPhone simulator. In a few moments when the leak check occurs you will see a red bar in the top part of the Leaks tool in the Track pane and a purple repeating bar below as you can see in Figure A-4. You have now collected the data that you need so stop Instruments from collecting data by clicking the Stop button in the top-left corner of the application. FIGURE A-4 Memory leak in Instruments 350 APPENDIX A TOOLS FOR TROUBLESHOOTING YOUR APPLICATIONS The red bar indicates that a leak was found and in fact .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.