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. Restricting QtConcurrent::blockingMap
Forum Updated to NodeBB v4.3 + New Features

Restricting QtConcurrent::blockingMap

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.6k Views 3 Watching
  • 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.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on last edited by
    #1

    We currently have the following call in our code:

    QtConcurrent::blockingMap(sequence, function);
    

    to call function once for eatch item in sequence. During some memory debugging, we noticed that this call is eating a lot of memory. We are willing to sacrifice some execution time to decrease the memory usage. We were wondering if one could somehow restrict the number of parallel executions of 'function' so that our memory consumption is not too high, but we could not find anything in the documentation at http://doc.qt.io/qt-4.8/qtconcurrent.html

    Is there a way to do this?

    Kind regards,
    Bart

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Hi,
      Try setting a fewer threads in the global pool (by default QThread::idealThreadCount is used):

      int threads = QThread::idealThreadCount() / 2;
      QThreadPool::globalInstance()->setMaxThreadCount(threads == 0 ? 1 : threads);
      

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What are you using as a container ?

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

        B 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What are you using as a container ?

          B Offline
          B Offline
          Bart_Vandewoestyne
          wrote on last edited by
          #4

          @SGaist said in Restricting QtConcurrent::blockingMap:

          What are you using as a container ?

          QVector, but I am wondering why you are asking this and why that is relevant? The high memory consumption is due to the fact that function does some OpenCV image processing on the stuff that is in sequence. Each call to function loads some images in memory and processes them. Doing that in parallel with QtConcurrent::blockingMap thus increases our memory usage dramatically, because we have lots of images loaded in memory. If we could limit the number of times function is run in parallel, we could somehow reduce the memory load (giving up some execution speed though, but we can probably live with that).

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bart_Vandewoestyne
            wrote on last edited by Bart_Vandewoestyne
            #5

            My question is no longer relevant. After some further investigation, it turned out that the high memory consumption was not in the call to QtConcurrent::blockingMap(sequence, function). The memory allocations are located after this call.

            Nevertheless thanks for the suggestions!

            1 Reply Last reply
            0

            • Login

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