How much memory foot print does a normal thread takes in java. Assuming that there is no object associated with it.
The short summary A thread stack will use 16kB of physical ram if it does nothing else but sleep. That is the base overhead of a JVM thread. Further stack memory consumption depends on the things you put in the stack.
In a section Thread, we can spot the same number in Reserved and Committed memory, which is very close to a number of threads * 1MB.
Threads generally consume from a shared memory. Hence threads do not own any specific memory.
All threads in a single process share all memory by default, and can access any of this memory at any time.
The amount of memory allocated for a thread stack is specific to your JVM Version + Operating System. It is configured with the -XX:ThreadStackSize option (-Xss on older versions.) Anecdotally 512KB is "normal", although it is 1024 on 64-bit linux which is probably the platform it's most commonly critical (one guy's opinion anyway)
Each thread in a Java application has its own stack. The stack is used to hold return addresses, function/method call arguments, etc And by default stack size is 512KB. You can change by -Xss
jvm command.
java -Xss128k
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With