M
moin
Hi,
we develop a server application, that has the request for very flexible
memory scalabilty: Normaly it uses only 200MiByte and sometimes up to
3GiByte memory. The server (RS6000 / AIX5.1L / JDK1.4.2 (32Bit)) runs
many other applications. Now the problem:
After GC the up to 2,5GiByte free (Java-)heap memory is _not_ returned
to the OS.
We write a small test class to check this issue (see below). It showes
(eg. svmon), that the physical memory is not released. We played around
with the JVM options described in 'IBM JVM Garbage Collection and
Storage Allocation techniques' without any success. We cross checked
our test with the SUN JVM (Linux and Windows 2000) and it works as
expected.
The question:
Does someone knows the correct parameter for the IBM JVM that enables
the shrinkage of the native heap?
Have we have to modify the AIX environment in a special way (eg
MALLOCTYPE)?
Bye Thomas
-------------- Test class -----------------
public class MemTest {
public static void main(String argc[]) {
java.util.ArrayList arrayList = new java.util.ArrayList();
int allocateStep;
int character;
if (argc.length > 0) {
System.out.println("Allocation Step: " + argc[0] + "MB");
allocateStep = Integer.parseInt(argc[0]);
} else {
System.out.println("Allocation Step: 128MB");
allocateStep = 128;
}
try {
character = System.in.read();
while (true) {
switch (character) {
case 'q':
System.exit(0);
break;
case 'a':
arrayList.add(allocate(allocateStep));
printStorage();
break;
case 'd':
if (arrayList.size() > 0)
arrayList.remove(0);
else
System.out.println("All arrays
deallocated");
printStorage();
break;
case 'g':
collectGarbage();
printStorage();
break;
case 'l':
printStorage();
break;
}
character = System.in.read();
}
} catch (Throwable aThrowable) {
aThrowable.printStackTrace();
}
}
static void printStorage() {
System.out.println("\n\nSpeicher (Max): " +
Runtime.getRuntime().maxMemory());
System.out.println("Speicher (Total): " +
Runtime.getRuntime().totalMemory());
System.out.println("Speicher (Frei): " +
Runtime.getRuntime().freeMemory());
System.out.println("\nSpeicher (Heap): " +
(Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory()));
}
static void collectGarbage() {
Runtime.getRuntime().runFinalization() ;
System.gc();
}
static byte[] allocate(int size) {
return new byte[size * 1024 * 1024];
}
}
we develop a server application, that has the request for very flexible
memory scalabilty: Normaly it uses only 200MiByte and sometimes up to
3GiByte memory. The server (RS6000 / AIX5.1L / JDK1.4.2 (32Bit)) runs
many other applications. Now the problem:
After GC the up to 2,5GiByte free (Java-)heap memory is _not_ returned
to the OS.
We write a small test class to check this issue (see below). It showes
(eg. svmon), that the physical memory is not released. We played around
with the JVM options described in 'IBM JVM Garbage Collection and
Storage Allocation techniques' without any success. We cross checked
our test with the SUN JVM (Linux and Windows 2000) and it works as
expected.
The question:
Does someone knows the correct parameter for the IBM JVM that enables
the shrinkage of the native heap?
Have we have to modify the AIX environment in a special way (eg
MALLOCTYPE)?
Bye Thomas
-------------- Test class -----------------
public class MemTest {
public static void main(String argc[]) {
java.util.ArrayList arrayList = new java.util.ArrayList();
int allocateStep;
int character;
if (argc.length > 0) {
System.out.println("Allocation Step: " + argc[0] + "MB");
allocateStep = Integer.parseInt(argc[0]);
} else {
System.out.println("Allocation Step: 128MB");
allocateStep = 128;
}
try {
character = System.in.read();
while (true) {
switch (character) {
case 'q':
System.exit(0);
break;
case 'a':
arrayList.add(allocate(allocateStep));
printStorage();
break;
case 'd':
if (arrayList.size() > 0)
arrayList.remove(0);
else
System.out.println("All arrays
deallocated");
printStorage();
break;
case 'g':
collectGarbage();
printStorage();
break;
case 'l':
printStorage();
break;
}
character = System.in.read();
}
} catch (Throwable aThrowable) {
aThrowable.printStackTrace();
}
}
static void printStorage() {
System.out.println("\n\nSpeicher (Max): " +
Runtime.getRuntime().maxMemory());
System.out.println("Speicher (Total): " +
Runtime.getRuntime().totalMemory());
System.out.println("Speicher (Frei): " +
Runtime.getRuntime().freeMemory());
System.out.println("\nSpeicher (Heap): " +
(Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory()));
}
static void collectGarbage() {
Runtime.getRuntime().runFinalization() ;
System.gc();
}
static byte[] allocate(int size) {
return new byte[size * 1024 * 1024];
}
}