Sunday Mar 12, 2006

Memory Optimization Observation

I was looking at reducing the memory consumed by some of the full document fidelty models we have for WSDL and XML Schema. I noticed that one of the representations was storing an unnecessary object reference. I was expecting the object reference multiplied by the large number of objects created to have an impact on the memory size, but removing this reference did not have any impact. The basic code to illustrate this issue is below (I ran this using 1.5.0_06). What I noticed was that removing the member variable i from class T did not have any impact in terms of memory usage. However, uncommenting the j variable from Class T had the expected impact of increasing the memory size. The test code import java.lang.management.ManagementFactory; public class MemoryTest { public static long getCurrentMemoryUsage() { ManagementFactory.getMemoryMXBean().gc(); return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed(); } static class Super { public Super(String s) { value = s; } public String getValue() { return value; } private String value; } static class T extends Super { public T() { super(T.class.getName()); } private int i; //private int j; } public static void testNormalRef(Object[] list) { for (int i = 0; i < list.length; i++) { list[i] = new T(); } } public static void main(String[] args) { final int numObjects = 100000; Object[] refs = new Object[numObjects]; testNormalRef(refs); long curUsage = getCurrentMemoryUsage(); System.out.printf("MemoryUsed %d\\n", curUsage); } }

Saturday Feb 04, 2006

JExamples.com Firefox search plug-in

There is now a Jexamples.com FireFox search plug-in on mycroft http://mycroft.mozdev.org/download.html?name=jexamples.com&submitform=Search. The plug-in allows searching from the firefox toolbar on Jexamples.com (which is a site for finding Java examples).
About

cwebster

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today