Reading notes-in-depth understanding of oom caused by JVM virtual machine -1.jvm-stack

Source: Internet
Author: User
Tags throwable
-xss128k: This JVM parameter is used to configure the stack size to 128k
Because the stack is thread-private (it is unclear to understand the structure of the JVM virtual machine), the exception is generated if we start a thread and call a recursive in the thread.


/** * VM args:-xss128k *  */public class Javavmstacksof {private int stacklength = 1;public void Stackleak () {Stackleng Th++;stackleak ();}  public static void Main (string[] args) throws Throwable {javavmstacksof oom = new javavmstacksof (); try {oom.stackleak ();} catch (Throwable e) {System.out.println ("stack length:" + oom.stacklength); throw e;}}}




Analysis:
1. Calling Javavmstacksof's Stackleak () method in the main thread and calling itself in Stackleak ()
2. Each call to itself generates a stack frame at a time (the stack frame is divided into three parts: the local variable area (Variables), the operand stack (Operand stack), and the frame data area), so it takes up a certain amount of space
3. The-xss128k we set up means that the main thread's stack space is only 128k. An oom exception occurs when the stack space is low-Exception in thread "main" Java.lang.StackOverflowError

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Reading notes-in-depth understanding of oom caused by JVM virtual machine -1.jvm-stack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.