Java Threads: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 22: Line 22:
==Java Thread Stack Memory Management==
==Java Thread Stack Memory Management==


The default thread stack size on 64-bit systems is 1024K. 64k is the least amount of stack space allowed per thread.
{{Internal|Java_Memory_Concepts#Thread_Stack_Memory_Management|Thread Stack Memory Management}}
 
It can be modified with with the <tt>-Xss</tt> option:
 
<pre>
java ... -Xss<size> ...
</pre>
 
where "<size>" represents the amount of memory and the measure unit (ex "2048k").
 
More about Java memory management can be found here {{Internal|Java_Memory#Concepts|Java Memory}}

Revision as of 17:54, 9 May 2017

Internal

Subjects

Concepts

Daemon Thread

Java Threads and Linux Processes

On a Linux system, each JVM thread counts as a "process", in that it is subject to system-wide and user-wide process number limitations - see "maximum number of processes allowed on a system" and "maximum number of processes available to a single user". When a JVM instance adjust its number of threads, the change is reflected by /proc/stat "processes" count.

For an example of what happens when the number of Linux processes allowed to an user is reached, see

OutOfMemoryError "unable to create new native thread"

A simple Java program that allows experimenting with threads:

https://github.com/NovaOrdis/playground/tree/master/java/threads/multiple-threads-spinning

Java Thread Stack Memory Management

Thread Stack Memory Management