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. QThread::start: Thread creation error: Resource temporarily unavailable

QThread::start: Thread creation error: Resource temporarily unavailable

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k Views 1 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.
  • M Offline
    M Offline
    mishas
    wrote on last edited by
    #1

    Hello.
    When I try to start over 500 threads using phantomjs the error is thrown:
    [WARNING] QThread :: start: Thread creation error: Resource temporarily unavailable

    Tell me what needs to be done to avoid this error?

    Thanks in advance

    $ulimit -a
    core file size (blocks, -c) 0
    data seg size (kbytes, -d) unlimited
    scheduling priority (-e) 0
    file size (blocks, -f) unlimited
    pending signals (-i) 514564
    max locked memory (kbytes, -l) unlimited
    max memory size (kbytes, -m) unlimited
    open files (-n) 1048576
    pipe size (512 bytes, -p) 8
    POSIX message queues (bytes, -q) 819200
    real-time priority (-r) 0
    stack size (kbytes, -s) 24576000
    cpu time (seconds, -t) unlimited
    max user processes (-u) 1000000
    virtual memory (kbytes, -v) unlimited
    file locks (-x) unlimited

    $uname -a
    Linux debian 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux

    $free
    total used free shared buff/cache available
    Mem: 131960164 18548424 104018312 1575544 9393428 110874136
    Swap: 134152188 0 134152188

    $lscpu
    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    Address sizes: 46 bits physical, 48 bits virtual
    CPU(s): 24
    On-line CPU(s) list: 0-23
    Thread(s) per core: 2
    Core(s) per socket: 6
    Socket(s): 2
    NUMA node(s): 2
    Vendor ID: GenuineIntel
    CPU family: 6
    Model: 45
    Model name: Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
    Stepping: 7
    CPU MHz: 2458.472

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mishas said in QThread::start: Thread creation error: Resource temporarily unavailable:

      Tell me what needs to be done to avoid this error?

      Don't start so many threads - or do you have 500 cores?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mishas
        wrote on last edited by mishas
        #3

        my task needs to run at least 700 threads.
        hardware allows it..
        just tell me, what "resource" I need to increase?
        Thank you.

        htop:
        htop.png

        when I using php cUrl, I can start over 1000 threads, but I need to run phantomjs...

        Christian EhrlicherC 1 Reply Last reply
        0
        • M mishas

          Hello.
          When I try to start over 500 threads using phantomjs the error is thrown:
          [WARNING] QThread :: start: Thread creation error: Resource temporarily unavailable

          Tell me what needs to be done to avoid this error?

          Thanks in advance

          $ulimit -a
          core file size (blocks, -c) 0
          data seg size (kbytes, -d) unlimited
          scheduling priority (-e) 0
          file size (blocks, -f) unlimited
          pending signals (-i) 514564
          max locked memory (kbytes, -l) unlimited
          max memory size (kbytes, -m) unlimited
          open files (-n) 1048576
          pipe size (512 bytes, -p) 8
          POSIX message queues (bytes, -q) 819200
          real-time priority (-r) 0
          stack size (kbytes, -s) 24576000
          cpu time (seconds, -t) unlimited
          max user processes (-u) 1000000
          virtual memory (kbytes, -v) unlimited
          file locks (-x) unlimited

          $uname -a
          Linux debian 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux

          $free
          total used free shared buff/cache available
          Mem: 131960164 18548424 104018312 1575544 9393428 110874136
          Swap: 134152188 0 134152188

          $lscpu
          Architecture: x86_64
          CPU op-mode(s): 32-bit, 64-bit
          Byte Order: Little Endian
          Address sizes: 46 bits physical, 48 bits virtual
          CPU(s): 24
          On-line CPU(s) list: 0-23
          Thread(s) per core: 2
          Core(s) per socket: 6
          Socket(s): 2
          NUMA node(s): 2
          Vendor ID: GenuineIntel
          CPU family: 6
          Model: 45
          Model name: Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
          Stepping: 7
          CPU MHz: 2458.472

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @mishas said in QThread::start: Thread creation error: Resource temporarily unavailable:

          [WARNING] QThread :: start: Thread creation error: Resource temporarily unavailable

          I would read e.g. https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable. First it discusses why it's not a great idea and what the issue might be.

          By the time you get to https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable/8 :

          After modifying /etc/security/limits.conf
          --with
          <myusername> soft nofile 150000
          <myusername> hard nofile 150000
          <myusername> soft nproc 150000
          <myusername> hard nproc 150000
          
          I can open about 34000 threads from the class QThread
          

          I believe that user is saying he went from 290 to 34,000, so might address your requirement. Then he says:

          after opening those threads,I can not execute any more commands in shell

          I get the error "bash: fork: Cannot allocate memory"

          :D

          M 1 Reply Last reply
          0
          • M mishas

            my task needs to run at least 700 threads.
            hardware allows it..
            just tell me, what "resource" I need to increase?
            Thank you.

            htop:
            htop.png

            when I using php cUrl, I can start over 1000 threads, but I need to run phantomjs...

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @mishas said in QThread::start: Thread creation error: Resource temporarily unavailable:

            my task needs to run at least 700 threads.

            What are you doing?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • JonBJ JonB

              @mishas said in QThread::start: Thread creation error: Resource temporarily unavailable:

              [WARNING] QThread :: start: Thread creation error: Resource temporarily unavailable

              I would read e.g. https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable. First it discusses why it's not a great idea and what the issue might be.

              By the time you get to https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable/8 :

              After modifying /etc/security/limits.conf
              --with
              <myusername> soft nofile 150000
              <myusername> hard nofile 150000
              <myusername> soft nproc 150000
              <myusername> hard nproc 150000
              
              I can open about 34000 threads from the class QThread
              

              I believe that user is saying he went from 290 to 34,000, so might address your requirement. Then he says:

              after opening those threads,I can not execute any more commands in shell

              I get the error "bash: fork: Cannot allocate memory"

              :D

              M Offline
              M Offline
              mishas
              wrote on last edited by
              #6

              @JonB said in QThread::start: Thread creation error: Resource temporarily unavailable:

              @mishas said in QThread::start: Thread creation error: Resource temporarily unavailable:

              [WARNING] QThread :: start: Thread creation error: Resource temporarily unavailable

              I would read e.g. https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable. First it discusses why it's not a great idea and what the issue might be.

              By the time you get to https://forum.qt.io/topic/22135/qthread-start-thread-creation-error-resource-temporarily-unavailable/8 :

              After modifying /etc/security/limits.conf
              --with
              <myusername> soft nofile 150000
              <myusername> hard nofile 150000
              <myusername> soft nproc 150000
              <myusername> hard nproc 150000
              
              I can open about 34000 threads from the class QThread
              

              I believe that user is saying he went from 290 to 34,000, so might address your requirement. Then he says:

              after opening those threads,I can not execute any more commands in shell

              I get the error "bash: fork: Cannot allocate memory"

              :D

              I read this post before posting.
              As you can see my
              $ulimit -a
              a lot more then in post:
              open files (-n) 1048576
              max user processes (-u) 1000000

              1 Reply Last reply
              1

              • Login

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