Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how much memory a thread takes in java [closed]

How much memory foot print does a normal thread takes in java. Assuming that there is no object associated with it.

like image 536
Ranger Avatar asked Jun 14 '12 05:06

Ranger


People also ask

How much RAM does a thread use?

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.

How much memory should a thread have?

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.

Does thread consume memory?

Threads generally consume from a shared memory. Hence threads do not own any specific memory.

Do Java threads share memory?

All threads in a single process share all memory by default, and can access any of this memory at any time.


2 Answers

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)

like image 151
Affe Avatar answered Oct 21 '22 21:10

Affe


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
like image 32
Subhrajyoti Majumder Avatar answered Oct 21 '22 21:10

Subhrajyoti Majumder