최대 JVM 힙 크기 검색

JVM_Info 클래스는 JVM의 최대 힙 크기를 검색합니다.
package customcode; 

import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices; 

import java.net.*;

/**
 * The JVM_Info class retrieves the maximum heap size of the JVM. 
 * It writes a message in the test log with the hostname where the
 * JVM is running and the JVM's maximum heap size in megabytes.
 */

/**
 * @author IBM Custom Code Samples 
 */

public class JVM_Info implements
        com.ibm.rational.test.lt.kernel.custom.ICustomCode2 { 

    public JVM_Info() {
    }

    public String exec(ITestExecutionServices tes, String[] args) { 		
        Runtime rt = Runtime.getRuntime();
        long maxMB = rt.maxMemory()/(1024*1024); // maxMemory() size is in bytes
        String hostName = "Unknown";
                
        try {
            hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e1) {
            tes.getTestLogManager().reportMessage("Can't get hostname");
            return null; 
        }
                
        tes.getTestLogManager().reportMessage("JVM maximum heap size for host "
                                        + hostName + " is " + maxMB + " MB");
        return null; 
     }
}

피드백