How to measure the performance of an Ionic 3 app?

2019-05-09 15:54发布

问题:

I have developed an app using Ionic 3 framework. I would like to measure the CPU and memory usage of my app. What is the best practice to do so?

回答1:

You must not use AndroidStudio and XCode to measure the memory usage of the Ionic app.

Why? Here is the comment from Ionic team member

Unfortunately we have not been able to reproduce this issue on our end. Would you mind checking your app on your device with safari dev tools instead of the memory tool in xcode? The reason I recommend this is because the xcode memory tools can be misleading in the fact that it's not actually measuring memory usage of the javascript heap of the app, instead, it is reading the memory used by the kernel / OS itself. So based off the same concept I described here, the OS will not free up memory used by the JS virtual machine if it 1. thinks the action that used that memory is going to happen often and 2. thinks that it has plenty of memory to spare. So, while the JS heap memory will be shrinking every time the JS engine runs garbage collection, that does not mean that the memory that iOS has allocated to the browser will shrink, and, if iOS did start freeing up memory when it has plenty of memory available you would actually see performance issues. Also, it's important to remember that high memory usage does not === a memory leak and in fact operating systems are built to take the most advantage of the resources (in this case ram) available to it, especially on mobile devices.

Tools:

Safari dev tools

Chrome dev tools