NIO.2 and GC fragmentation

Alan Bateman Alan.Bateman at Sun.COM
Sun Jan 18 09:53:54 PST 2009


Mark Thornton wrote:
> Java direct buffers aren't allocated from the Java heap (the buffer 
> itself that is, not the object which wraps it)! They are allocated 
> using the OS runtime and don't affect the garbage collector. The JVM 
> has limit (default 64MB I seem to recall) of total direct buffer 
> allocation. What can be a problem is disposing of them --- the memory 
> is released by a cleanup thread after the object has become 
> unreachable. However you can run short of memory for direct or memory 
> mapped buffers, while still having plenty of free space in the Java heap.
That's right although the maximum is tied to the maximum size of the 
java heap (and may be configured via the -XX:MaxDirectMemorySize option).

-Alan.



More information about the nio-discuss mailing list