`

小tips:设置java 的heap

阅读更多
在java中,可以设置heap的大小:
-Xms<size> 设置初始heap的大小
-Xmx<size>  设置最大的heap的大小
-xss<size>设置thread stack 大小
如下文,设置
java -Xms64m -Xmx256m HelloWorld 会设置helloworld这个应用的heap大小最大为256M,
在程序中也可以读取的,比如:
public class GetHeapSize { 
   public static void main(String[]args){   
       //Get the jvm heap size.    
    long heapSize = Runtime.getRuntime().totalMemor();
  //Print the jvm heap size. 
       System.out.println("Heap Size = " + heapSize);  
  }
}
分享到:
评论

相关推荐

    JBOSS 备忘录 TIPS 操作手册

    同时,`-Xmx512m`参数用于设置堆内存(Heap)的最大值,以防止`java.lang.OutOfMemoryError: Java heap space`的错误发生。 #### 2. 在Windows系统下将JBoss作为服务运行 在Windows系统中,可以利用`JavaService....

    2008年sun深圳站培训资料

    #### 一、Java性能优化工具与技巧 (Tools and Tips: Improving Java Performance) **主讲人:** Joey Shen, Technology Evangelist, Sun Microsystems Inc. #### 二、议程 (Agenda) 1. **Hotspot VM 的内存管理 ...

    Java邮件开发Fundamentals of the JavaMail API

    Looking to incorporate mail facilities into your platform-independent Java solutions? Look no further than the JavaMail API, which offers a protocol-independent model for working with IMAP, POP, ...

    The Busy Coders Guide to Android Development最终版2019

    Issues with Application Heap Finding Memory Leaks Issues with System RAM Issues with Battery Life Power Measurement Options Sources of Power Drain Addressing Application Size Issues Crash Reporting ...

    CommonsWare.The.Busy.Coders.Guide.to.Android.Development.Version.8.2.2017

    Improving CPU Performance in Java Finding and Eliminating Jank Issues with Bandwidth Focus On: TrafficStats Measuring Bandwidth Consumption Being Smarter About Bandwidth Issues with Application Heap ...

Global site tag (gtag.js) - Google Analytics