When an OutOfMemoryError occurs in Java

Source: Internet
Author: User
Tags xms

If the following stack trace information appears when you run the Java program: Java code: java. SQL. SQLException: java. lang. outOfMemoryError: Java heap space at com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 1073) at com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 987) at com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 982) at com. mysql. jdbc. SQLError. createSQLException (SQLError. java: 927) at com. mysql. jdbc. util. handleNewInstance (U Til. java: 435) at com. mysql. jdbc. PreparedStatement. getInstance (PreparedStatement. java: 872) indicates that the program consumes the maximum memory that JVM can use the operating system. In this case, you can check whether the code is suspected of excessive object creation. If not, you can use non-standard options in the java command line. For more information, see http://www.software8.co/wzjs/java/2820.htmlcommandcode:-Xmsp-Xmxp (-Xms and-Xmx's first X must be capitalized; otherwise, it cannot) the first parameter specifies the initial memory size, such as set to 5 MB and-Xms5m. (M or M) The second parameter specifies the maximum memory, that is, the maximum memory value that the JVm can obtain from the operating system. For example, set it to 10 M-Xmx10m. Generally, the initial size is smaller than the maximum value. -Xms <-Xmx: Command code: java-Xms128m-Xmx256m

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.