반응형
=================================
=================================
=================================
참고:
http://ko.w3support.net/index.php?db=so&id=52353
출처:
import java.lang.instrument.Instrumentation;
import java.util.Calendar;
public class Test {
private static Instrumentation inst;
public static void premain(String options, Instrumentation inst) {
Test.inst = inst;
System.out.println("options= " + options);
Class[] loaded = inst.getAllLoadedClasses();
for (Class clazz : loaded) {
System.out.println(clazz);
}
}
public static long sizeOf(Object o) {
assert inst != null;
return inst.getObjectSize(o);
}
public static void main(String[] args) {
System.out.println("Size of Object: " + sizeOf(new Object()));
System.out.println("Size of direct subclass: " + sizeOf(new Test()));
System.out.println("Size of Calendar: "
+ sizeOf(Calendar.getInstance()));
}
}
// 매니페스트 설정
First, create a MANIFEST.MF file, and add the following content in it.
Manifest-Version: 1.0
Premain-Class: Test
Second, package the class and MANIFEST.MF into a jar file test.jar
Third, run the program by command:java -ea -javaagent:est.jar
import java.util.Calendar;
public class Test {
private static Instrumentation inst;
public static void premain(String options, Instrumentation inst) {
Test.inst = inst;
System.out.println("options= " + options);
Class[] loaded = inst.getAllLoadedClasses();
for (Class clazz : loaded) {
System.out.println(clazz);
}
}
public static long sizeOf(Object o) {
assert inst != null;
return inst.getObjectSize(o);
}
public static void main(String[] args) {
System.out.println("Size of Object: " + sizeOf(new Object()));
System.out.println("Size of direct subclass: " + sizeOf(new Test()));
System.out.println("Size of Calendar: "
+ sizeOf(Calendar.getInstance()));
}
}
// 매니페스트 설정
First, create a MANIFEST.MF file, and add the following content in it.
Manifest-Version: 1.0
Premain-Class: Test
Second, package the class and MANIFEST.MF into a jar file test.jar
Third, run the program by command:java -ea -javaagent:est.jar
=================================
=================================
=================================
반응형
'JAVA' 카테고리의 다른 글
[java] HttpURLConnection을 이용한 POST연동방식 (0) | 2011.04.01 |
---|---|
[java] 이클립스로 Jar가 포함된 실행 가능한 Jar 만들기 (0) | 2011.03.23 |
[java] URLConnect 관련 질잡 모음 (0) | 2011.03.23 |
[java] URLConnection을 이용한 파일 전송 (0) | 2011.03.23 |
[java] Java - String 을 InputStream 으로 만들기 (0) | 2011.03.22 |