Pay attention to the development of multi-threaded applications

Pay attention to the development of multi-threaded applications

For example: a 32-bit Window is limited to 2GB. Virtual machines provide maximum parameters to control the two parts of Java memory heap and method area.
2GB (operating system limits) minus the Xms (maximum heap size), MaxPermSize minus (maximum capacity method area), the program counter memory consumption is very small (negligible). If the virtual machine process within the province consumes memory skills are not counted, the remaining memory on the virtual machine stacks and stacks native method "divide" the. The larger allocation to each thread stack capacity, the number of threads that can be established naturally less, the easier it will run out of memory when creating the rest of the thread.
VM default parameters, the stack depth in most cases (for each method is not pushed onto the stack frame size is not the same, we can only say that in most cases) from 1000 to 2000 to reach no problem for normal method invocation (including recursion), this depth should be enough. However, if too many threads lead to the establishment of memory overflow, without being able to reduce the number of threads or replace the 64-bit virtual machine, it can only exchange for more threads by reducing the maximum stack and reducing stack capacity.

Published 30 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/wg22222222/article/details/83051184