Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much memory does my java thread take?

Is there a way to find out how much memory my java thread is taking in the VM?

For example, using stack trace dump, or some other means.

Thanks

like image 332
Vikas Jain Avatar asked Jan 06 '11 19:01

Vikas Jain


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.

Do threads consume memory?

Threads generally consume from a shared memory. Hence threads do not own any specific memory. If any threads work on a scope with variables, a memory profiler would help you get that information.


1 Answers

Java threads use the heap as shared memory. Individual threads have their stack (the size of which you can set via the -Xss command line option, default is 512KB), but all other memory (the heap) does not belong to specific threads, and asking how much of it one specific thread uses simply does not make sense.

like image 70
Michael Borgwardt Avatar answered Oct 23 '22 03:10

Michael Borgwardt