1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Increasing RH 8.2 threads

Discussion in 'Linux and Unix' started by elg3ne, Apr 28, 2004.

Thread Status:
Not open for further replies.
  1. elg3ne

    elg3ne Thread Starter

    Apr 27, 2004
    Hi guys, I have RH 8.2 box with tomcat 5 & apache with latest java version...

    I have a game running with java, & when the game hits its players limit sometime there is "java lang error"...

    As far as I know linux has only 1028 thread limit... Now I want to increase the limit because java uses lots of threads...

    Is there any one know how to increase the linux threads?

  2. tsunam


    Sep 14, 2003
    Seems to be that within linux its based on the ammount of space you allocate to the thread creation within the -Xxm settings, seems to be part of it. Thats more of a patch type thing then a fix. To get it closer to max you'll have to basically manually edit a couple of files and then recompile the program to be used.

    + max user processes (use "ulimit -u" to adjust)
    + thread limit, this is calculated based on the amount of physical memory
    (you can change it by editing /proc/sys/kernel/threads-max) (this is probably the easiest way to change it)
    + virtual memory. 32bit Linux by default allows 2GB virtual address space
    in user application. Unless you specify a smaller stack size (-Xss96k
    will do it), java will run out of virtual space in about 4000 threads
    (default stack size is 512k, 2GB/512k = 4096, but notice that the
    virtual memory is also used for C heap, library image, data segments, et al.)

    thoses are the various answers i have run across. Basically you modify the stack size. change the max process's as you need. And you can modify the thread count within your kernel so that it'll allow more.

    to increase the limits, you have to recompile glibc. Oh fun!.
    And the patch is essentially two lines!. Woohoo!

    --- ./linuxthreads/sysdeps/unix/sysv/linux/bits/local_lim.h.akl Mon Sep 4
    19:37:42 2000
    +++ ./linuxthreads/sysdeps/unix/sysv/linux/bits/local_lim.h Mon Sep 4
    19:37:56 2000
    @@ -64,7 +64,7 @@
    /* The number of threads per process. */
    /* This is the value this implementation supports. */
    -#define PTHREAD_THREADS_MAX 1024
    +#define PTHREAD_THREADS_MAX 8192

    /* Maximum amount by which a process can descrease its asynchronous I/O
    priority level. */
    --- ./linuxthreads/internals.h.akl Mon Sep 4 19:36:58 2000
    +++ ./linuxthreads/internals.h Mon Sep 4 19:37:23 2000
    @@ -330,7 +330,7 @@
    THREAD_SELF implementation is used, this must be a power of two and
    a multiple of PAGE_SIZE. */
    #ifndef STACK_SIZE
    -#define STACK_SIZE (2 * 1024 * 1024)
    +#define STACK_SIZE (64 * PAGE_SIZE)

    /* The initial size of the thread stack. Must be a multiple of PAGE_SIZE.
    * */

    Now just patch glibc, rebuild, and install it. ;-> If you have a
    package based system, I seriously suggest making a new package
    and using it.

    another way to do it.

    as well here are a few links that explain it better then i can :)
    http://www.jlinux.org/server.html (this one is the most comprehensive though and explains it all out for you :) ) So start here ^.^

    Interestingly enough I actually found this informative, because there's no doubt times when we all hit a no more threads can be made.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/224540

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice