Where does the stack memory allocated to the stream come from?

I have few questions regarding java GC and memory management.

In java, we define the upper bound of the process memory and the lower bound using the xmx and xms parameters. Using these parameters, the JVM allocates a young old and Perm space. So, if new threads are created, and then from the memory that is stored in the memory, is allocated to the threads? is it from real space or any other space?

Also, static class variables are allocated to which space is young, old or Perm space? (I suppose perm?)

The XmX parameter limits the young + old generation to either young + old + perm gen or young + old + perm + stack size ??

thank

+3
source share
3 answers

Basically, the memory stack comes from the stack area, which is independent of the heap area and perm area.

Static variables are allocated on the heap, except for string and numeric constants.

Parameter

-Xmx limits only the young + old parts of the heap, since the area of ​​permanence is not part of this.

The size of the stack area is set using the flag -Xss, the size of the heap area is set by the flag -Xmx, and the size of the perm area is set -XX:MaxPermSize.

If you want to dive into managing the internal memory of the JVM, I recommend this entry.

+4
source

The thread stack space is controlled by another option -Xss. Here is a link that can help you in this particular topic.

0

on solaris, you can use "ulimit -a" to see the process stack limit. I think the thread stack is taken from this resource. I am wondering if the JVM will issue garbage collection when there is enough space in the heap for threads, but not enough space for their stack.

0
source

Source: https://habr.com/ru/post/1766555/


All Articles