Does Xcode's Debug Navigator work different from Instruments allocations?

你说的曾经没有我的故事 提交于 2020-01-24 03:54:29

问题


I'm trying to find memory issues in my app.

When I use Xcode's debug navigator for memory issues I see increase in the overall usage of the application. For a specific flow, when I go back and forth I don't see memory being persisted.

However if I go through same flow and instrument using Allocations, I do see 3Mbs getting persisted every time I go back and forth.

Is Xcode's debug navigator not reliable or they're measuring something different or something else?!

EDIT:

So I've been told the difference is due to the build configuration. OK. But if I go and 'edit scheme' and change the build configuration to 'release' and run on my device. Can I then expect the Xcode debug navigator to work the same? Or still there are some differences? If so what?


回答1:


Is Xcode's debug navigator not reliable or they're measuring something different

Absolutely yes! As I have advised here many times (here for example), you must never draw real conclusions from the debug navigator gauges. Memory allocation works completely differently in a debug build in the simulator. If you want to know how your app's memory works, you must use Instruments so that you get a release build, and you must run on a device so that your memory usage reflects real-world conditions.

But if I go and 'edit scheme' and change the build configuration to 'release' ... Can I then expect the Xcode debug navigator to work the same

Absolutely no! Release means all sorts of compiler optimizations are performed that make the debugger almost impossible to use. But that doesn't matter; you would never debug and use Instruments to measure anything at the same time.




回答2:


Xcode's default behavior is to use a debug build when running your project in Xcode and to use a release build when profiling the project in Instruments. Debug and release builds can have different amounts of memory usage.

You can check and change the build configuration from Xcode's scheme editor.

If that doesn't solve your issue, you're going to have a tough time getting a definitive answer. The people who know the inner workings and the differences between the debugger and Instruments are Apple engineers.



来源:https://stackoverflow.com/questions/52563717/does-xcodes-debug-navigator-work-different-from-instruments-allocations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!