On this page

Analyze CPU usage

With Perf, you can analyze the CPU and memory usage of an application on Linux desktop and embedded devices. CPU Sampling uses the Perf tool bundled with the Linux kernel to take periodic snapshots of the call chain of an application and visualizes them in a timeline view or as a flame graph.

Usually, CPU Sampling needs debug symbols for the profiled binaries. Profile builds produce optimized binaries with separate debug symbols, so use them for profiling.

Collect data

To collect data:

  1. Go to Profile to open the Profile mode.
  2. In Backend, select CPU Sampling.
  3. In Profile, select Startup Project to profile the current project, or Custom Executable to profile another application. In Executable, Arguments, and Working directory, specify the application to start. To profile an application that is already running, select Attach to a running process.
  4. Select Start Recording to start the application and collect data. To start the application without collecting data, select Start Paused.

CPU Sampling start page

While the application runs, the recording page shows the time that the recording has been running. Select Pause to pause the data collection without ending it, and Resume to continue.

Select Stop Recording to stop and open the collected samples in a trace editor. As the data is passed through the Perf tool and an extra helper program bundled with Qt Creator, and both buffer and process it on the fly, processing the samples can take several seconds.

CPU Sampling trace editor tabs

Profile memory usage on devices

To create trace points for profiling memory usage on a target device:

  • Go to Analyze > CPU Sampling Options > Create Memory Trace Points.
  • Select Create trace points for memory profiling on the target device on the CPU Sampling toolbar.

In the Create Memory Trace Points dialog, modify the script to run.

Create Memory Trace Points dialog

If you need root privileges to run scripts as root, select the privileges to use in Elevate privileges using.

Select OK to run the script.

To add events for the trace points, see Choosing event types.

Record a memory trace to view usage graphs in the samples rows of the timeline and to view memory allocations, peaks, and releases in the flame graph.

Generate separate debug info for qmake projects

To manually set up a build configuration that generates debug symbols also for applications compiled for release, edit the build settings of a qmake project:

  1. Go to Projects > Build Settings.
  2. In Separate debug info, select Enable.
  3. Select Yes to recompile the project.

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.