Nominate our 2022 Qt Champions!

Processor occupancy

  • Hi everyone,

    I have a problem with my processor occupancy.
    I am working on Windows 7, my processor is an Intel core i5 4460 (4 cores 4 threads).
    I created a cpp qt program with a main thread (GUI), and two others threads (one for an Ethernet communication and the other to read a file).
    I had a problem on this program (now solved) which occupied a lot the processor. But the maximal processor occupancy was 50%. I don't know why ...
    Do you have an idea ?

    Thank you !

  • Hi! Did I get this right, you're basically complaining that your bug only fried a single core? :-D

  • I'm not sure I understand the problem, but you could be looking at a feature of the processor hardware. With i5 and i7 processors, it can actually split a single thread across more than one processor core. In theory this prevents poor performance from a processor-hungry process. Historically this was not done because the cache thrashing would negate any benefit. However, i5 and i7 has a cache for each core in addition to the L3 cache shared by all. I have seen this same behavior in my application. It employs a genetic algorithm which gobbles up 100% of the processor for 10+ seconds at a time. However, when I look at the performance tab of Task Manager, I see its actually splitting it across two cores at 50% each.

  • I wanted to know why I can't go above 50%, while I have got 3 threads ...

  • @ADVUser said in Processor occupancy:

    I wanted to know why I can't go above 50%, while I have got 3 threads ...

    Maybe your processing has some blocking command, which result in an average usage of 2 threads running at full speed. Fortunately, N threads in a program does not necessarily in N / n cores used at 100%.

  • Just as a test, the following should work:


    #ifndef HEATER_H
    #define HEATER_H
    #include <QObject>
    class Heater : public QObject
        explicit Heater(QObject *parent = 0);
    public slots:
        void process();
    #endif // HEATER_H


    #include "heater.h"
    Heater::Heater(QObject *parent)
        : QObject(parent)
    void Heater::process()
        auto a = 0;
        auto b = 0;
        while (true) {
            a = ++b * ++a;


    #include <QCoreApplication>
    #include <QThread>
    #include "heater.h"
    int main(int argc, char *argv[])
        QCoreApplication a(argc, argv);
        const auto thread_count = 8;
        for (auto i=0; i<thread_count; ++i) {
            QThread* thread = new QThread;
            Heater* heater = new Heater();
            QObject::connect(thread, &QThread::started, heater, &Heater::process);
        return a.exec();

  • Thank you for this code, it explains such things...
    It is interresting to modulate the thread count number
    Bye !

Log in to reply