Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidgets Application - High CPU Usage
QtWS25 Last Chance

QWidgets Application - High CPU Usage

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    webzoid
    wrote on 30 Oct 2017, 20:03 last edited by
    #1

    I've noticed over the past few days that my QWidgets application seems to have pretty high CPU usage and I really can't understand why or what is causing this high CPU usage.

    Looking at Task Manager in Windows 10, when the application is idle, nearly 50% of the CPU time is being used by my application. When I say my application is idle, literally nothing is going on - no threads running, no displays updating, nothing. If I pause the debugger, it hits the following line in main.cpp:

    QApplication a(argc, argv);
    
    // Initialize my application state here...
    
    MainWindow w;
    w.showMaximized();
    
    return a.exec();
    

    When I "initialize my application state", I load in a settings file using QSettings, prepare a few variables and call a few functions but then the application shows the MainWindow before going idle while waiting for the user to click a "connect" button which hooks up a number of threads, etc and connects to various hardware devices via QSerialPorts. At the time of checking the high CPU time, none of this has happened.

    What debugging features available in Qt Creator can help me figure out what is going on? This seems really unusual behaviour.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 30 Oct 2017, 20:08 last edited by
      #2

      Hi,

      Callgrind could be used and you might want to also take a look at KDAB's HotSpot project.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      W 1 Reply Last reply 30 Oct 2017, 20:17
      1
      • S SGaist
        30 Oct 2017, 20:08

        Hi,

        Callgrind could be used and you might want to also take a look at KDAB's HotSpot project.

        Hope it helps

        W Offline
        W Offline
        webzoid
        wrote on 30 Oct 2017, 20:17 last edited by webzoid
        #3

        @SGaist Thanks, although I don't seem to be able to get callgrind to work.

        When I follow the instructions, select "callgrind" from the drop-down and click "Start analysis", nothing happens...

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pablo J. Rogina
          wrote on 30 Oct 2017, 20:29 last edited by
          #4

          @webzoid For Valgrind integration with Qt Creator, take a look at this.
          However, most of the Valgrind tool set is intended to be run under Linux, and you have mentioned Windows 10... Is it possible for you to run your application under Linux? at least to check if it behaves the same and in such case to go ahead with profiling session.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          W 1 Reply Last reply 30 Oct 2017, 20:38
          0
          • P Pablo J. Rogina
            30 Oct 2017, 20:29

            @webzoid For Valgrind integration with Qt Creator, take a look at this.
            However, most of the Valgrind tool set is intended to be run under Linux, and you have mentioned Windows 10... Is it possible for you to run your application under Linux? at least to check if it behaves the same and in such case to go ahead with profiling session.

            W Offline
            W Offline
            webzoid
            wrote on 30 Oct 2017, 20:38 last edited by
            #5

            @Pablo-J.-Rogina Unfortunately I don't have access to a Linux machine. There is scope to set up an Ubuntu VM however I've only got a small SSD in my laptop and it would mean clearing the way somehow.

            I think I'll just have to do it the old fashioned blood-and-thunder way using qDebug() statements.

            W 1 Reply Last reply 30 Oct 2017, 20:39
            0
            • W webzoid
              30 Oct 2017, 20:38

              @Pablo-J.-Rogina Unfortunately I don't have access to a Linux machine. There is scope to set up an Ubuntu VM however I've only got a small SSD in my laptop and it would mean clearing the way somehow.

              I think I'll just have to do it the old fashioned blood-and-thunder way using qDebug() statements.

              W Offline
              W Offline
              webzoid
              wrote on 30 Oct 2017, 20:39 last edited by
              #6

              Having said that the application is idle, there is some QML loaded in at this point into a QQuickWidget - would the rendering loop for this cause high CPU usage?

              1 Reply Last reply
              0

              6/6

              30 Oct 2017, 20:39

              • Login

              • Login or register to search.
              6 out of 6
              • First post
                6/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved