NIO.2 and GC fragmentation

Alan Bateman Alan.Bateman at Sun.COM
Sun Jan 18 09:51:28 PST 2009


Leon Finker wrote:
> Hi,
>
> While at it, I decided to comment on the other half of the problem that
> existed in early .NET versions and sockets API: GC fragmentation. When
> calling out to OS native API, the buffers that we pass in from .NET world
> are "pinned" and used directly by the underlying OS native API. What this
> means is that GC is unable to move these buffers around in order to compact
> the heap until native API returns to managed world. Since on a server
> thousands of buffers can be pinned while waiting for I/O to happen this
> caused a great deal of heap fragmentation. 
>
> Is it correct to assume that Java in a sense also "pins" the Java direct
> buffers that it uses in JNI and those prevents GC from moving these buffers
> and compacting the heap until native API returns? Thank you in advance for
> feedback
>   
There is no pinning as direct buffer reside outside of the java heap.

-Alan.



More information about the nio-discuss mailing list