M
Mike
The following code fails with OutOfMemoryError
but if I uncomment System.gc() call, everything "works".
Yes, I am aware that direct buffer is allocated in system memory. But
still, why isn't garbage collector automatically called, when there is
no more "system" memory available? Since there is no direct way to
"disallocate" direct buffer, it should be.
What is that, a bug?
P.S.
jdk 1.4.1_05-b4
Windows XP Prof
512Mb RAM
Code:
final int SIZE = 15000;
int N = 500000;
long start = System.currentTimeMillis();
for (int i = 0; i < N*5; i++) {
ByteBuffer buf1 = ByteBuffer.allocateDirect(SIZE);
// System.gc();
}
long timeHeap = System.currentTimeMillis() - start;
but if I uncomment System.gc() call, everything "works".
Yes, I am aware that direct buffer is allocated in system memory. But
still, why isn't garbage collector automatically called, when there is
no more "system" memory available? Since there is no direct way to
"disallocate" direct buffer, it should be.
What is that, a bug?
P.S.
jdk 1.4.1_05-b4
Windows XP Prof
512Mb RAM