Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java thread stack size on 64-bit linux

My goal is to come up with figure of max threads which can run in parallel. I was pointed to many links by Google, where they give simple math by dividing the RAM/StackSize. In 64 bit Linux, we have thread stack size defined as 10 MB(ulimit -s = 10240kb) and RAM was 4GB, leaving 1 GB for OS and going with this math I can have ~300 threads or so but small test application which I wrote goes upto ~32297 and then gives out of memory error.

I tried different values with -Xss but these values hardly have any effect on thread count, it remains same as ~32297).

This gave me an impression that stack size is variable and decided by OS and goes upto max defined by us whenever needed, but wherever I read, they size stack size is static

What exactly I'm missing here?

like image 356
Gaurav Avatar asked Oct 27 '25 04:10

Gaurav


1 Answers

Try checking/changing linux maximum stack size using

ulimit -s

Also check for linux threads limit

cat /proc/sys/kernel/threads-max  
like image 169
a-- Avatar answered Oct 29 '25 18:10

a--



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!