Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 413
mfaani Avatar asked Sep 28 '18 23:09

mfaani


2 Answers

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.

enter image description here

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.

like image 168
Swift Dev Journal Avatar answered Nov 19 '22 18:11

Swift Dev Journal


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.

like image 2
matt Avatar answered Nov 19 '22 17:11

matt