Very long full GCs cause audio glitches due to memory and disk thrashing

Hi,

I've written a small application which plays audio in real time. Everything works fine, except when I use it on a computer where memory is scarce. In particular, I get audio glitches whenever a full garbage collection occurs.

I suspect this happens because most of the heap has been swapped out onto disk, so whenever the garbage collection occurs the entire process blocks until the entire object graph has been traversed. Given that the disk is heavily loaded, this usually takes about 45 seconds, even though the process is run at real-time priority (Windows).

Is there any way to force the entire heap to be non-swappable? I don't mind wasting 10-20 Mbs of RAM...

Pointers to any other plausible solution would be greatly appreciated. =)

By the way, I've tried switching to different garbage collectors, but they don't seem to fix the problem, although it sometimes occurs less often..

[935 byte] By [volley_sea] at [2007-10-3 11:23:10]
# 1

This definitely sounds like a situation where you're getting into swapping.Try a smaller maximum heap size if you can - something less than the total amount of physical memory. The long pauses should definitely go down if you can do that.

From the VM side there's nothing that I know of that will lock the heap into physical memory.

jon999a at 2007-7-15 13:48:38 > top of Java-index,Java HotSpot Virtual Machine,HotSpot Internals...