The debug navigator is a tool used to find issues with performance and hardware usage in your applications. This tutorial shows how to use the debug navigator to find out if your application is using too much CPU, memory, or other resources.
- [Instructor] The debug navigator can help you find issues in your code in regards to memory and CPU usage. You may have noticed those buttons in the debug navigator while your application is running. So if you're running any app, look in the debug navigator. So, leave it running, go to Xcode, make sure you select the debug navigator, and really, what you're concerned with here is CPU and memory. Let's go to memory first. The memory section shows how much memory your app is currently using, and this comes in real time, and it gives you this chart.
And when you have a straight horizontal line, your app is continuing to use the same amount of memory. You may see spikes in this if you create a game, for example, and you're loading a lot of assets, but it should, generally, stay flat if you can help it. What you really want to avoid is your app always continuing to use more memory. So this is sloping upward and never going down at all. You have some problem in your code that's using too much memory.
Maybe you're loading assets in and not discarding them at the appropriate time. So keep this in mind when you're using your applications. Maybe you get a crash and you have no idea why the crash is happening. This is a great place to check if that ever happens. In this memory menu, you'll also have the usage comparison showing what your app is using compared to what the other processes on your machine are using. Now, when I say machine, right now I'm talking about my computer as I'm recording this, but really, what you're concerned with is how much device memory is being used.
So you test this on a device and you can see how much memory your app is using in comparison to your operating system, so iOS on an iPhone, for example. You can see how many resources are free. When you run out of free resources, your app is going to crash. So, again, keep that in mind. You really want to pay attention to this horizontal plane. If it's going up, you have a problem, and you might eventually get a crash. Let's head over to CPU, and in here, we can look at the percentage of CPU that's used by their application.
You can also compare that to other apps that are running on the device. The main thing you want to keep in mind with CPU usage is that newer devices have more power than older devices. So if you want your app to run on older devices, then don't max out its usage on a current device. If you do that, performance may be worse on older devices. So just keep that in mind, how much CPU your app is using when you test it.
And remember, when you're testing, it's best to test on as many devices as possible, so that you can compare performance and make sure that your app's performance is up to your standards on all the devices you want to support.