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. [Solved]QT 5.4.1 QTimer using up all handles for Window Manager Objects

[Solved]QT 5.4.1 QTimer using up all handles for Window Manager Objects

Scheduled Pinned Locked Moved General and Desktop
qtimerwindow managerhandles
7 Posts 3 Posters 10.2k 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.
  • C Offline
    C Offline
    Cob50nm
    wrote on 21 May 2015, 10:01 last edited by Cob50nm
    #1

    I am using a QTimer to trigger a recurring call to a function, however it eventually crashed with the following errors

    QEventDispatcherWin32::registerTimer: Failed to create a timer (The current process has used all of its system allowance of handles for Window Manager objects.)
    struct HWND__ *__cdecl qt_create_internal_window(const class QEventDispatcherWin32 *): CreateWindow() for QEventDispatcherWin32 internal window failed (The current process has used all of its system allowance of handles for Window Manager objects.)
    Qt: INTERNAL ERROR: failed to install GetMessage hook: 1158, The current process has used all of its system allowance of handles for Window Manager objects.
    

    And as stated in this link, timer objects take up these handles. Is there a way to stop this? My program needs to be running all the time without being restarted and without user input, and increasing the system allowance (as some people suggest) seems like it would just delay the crash rather than prevent it.

    Timer code

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(mFunc()));
    timer->start(15000);
    

    The timer is not recreated anywhere else, or called multiple times.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 May 2015, 21:31 last edited by
      #2

      Hi and welcome to devnet,

      Despite the message, your QTimer is probably innocent, how many widgets/windows are you creating with your application ?

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Cob50nm
        wrote on 22 May 2015, 08:12 last edited by
        #3

        It is making 3 windows, 2 of which are web views which poll a server.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 May 2015, 22:06 last edited by
          #4

          Ok, then what does happen in mFunc ?

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mcosta
            wrote on 22 May 2015, 22:20 last edited by
            #5

            Hi,

            how @SGaist said the message says something about creating resources.
            You timer is called every 15 seconds so I guess the guilty code is inside myFunc(). Could you show it?

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Cob50nm
              wrote on 25 May 2015, 08:56 last edited by
              #6

              sure, here it is

               void MainWindow::mFunc()
              {
                   mTime
                   // send tim url thing
                   QNetworkAccessManager *manager = new QNetworkAccessManager(this);
              
              if(ui->s1_AutoCycle->isChecked())
              {
                  QString url = makeURL(1,1);
                  screen1->setUrl(url);
                  ui->s1_showing->setText("Screen 1 : " + url);
              }
              else
              {
                  s1_max = 24;
                  QNetworkReply *reply21 = manager->get(QNetworkRequest(QUrl("myUrl.php?param=x")));
                  connect(reply21, SIGNAL(finished()), this, SLOT(set_s1()));
              }
              
              if(ui->s2_AutoCycle->isChecked())
              {
                  QString url = makeURL(2,1);
                  screen2->setUrl(url);
                  ui->s2_showing->setText("Screen 2 : " + url);
              }
              else
              {
                  s2_max = 24;
                  QNetworkReply *reply22 = manager->get(QNetworkRequest(QUrl("myUrl.php?param=x")));
                  connect(reply22, SIGNAL(finished()), this, SLOT(set_s2()));
              }
              mTimer->start(15000);
              }
              
              1 Reply Last reply
              0
              • C Offline
                C Offline
                Cob50nm
                wrote on 25 May 2015, 09:17 last edited by
                #7

                Actually I have since spotted what the problem was, As it turns out creating a new instance of QNetworkAccessManager every 15 seconds is not the best idea if you're not deleting them.

                The solution I went with was making *manager a class member.

                1 Reply Last reply
                0

                1/7

                21 May 2015, 10:01

                • Login

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