6999915: TEST_BUG: test/java/nio/channels/AsynchronousSocketChannel/Leaky.java failed intermittently (win)

Alan Bateman Alan.Bateman at oracle.com
Mon Nov 15 04:08:13 PST 2010


This is a test fix, to address an illusive test failure that  happens 
intermittently when running on legacy editions of Windows installed on 
fast machines. To understand the test failure requires a bit of background:

1. Legacy editions of Windows (XP and Windows Server 2003) don't support 
thread agnostic I/O. When an attempt is made to initiate an I/O 
operation on a non-pooled thread, as in this test, then it causes a task 
to be submitted to the thread pool so that the I/O operation is 
initiated on a pooled thread.

2. The default thread pool, as used by this test, is a cached thread 
pool and so creates threads as needed.

3. I/O operations on ByteBuffers that are backed by an array in the heap 
require copying the bytes in/out of temporary direct buffers. To avoid a 
malloc/free per I/O operation, the direct buffers are maintained in 
per-thread cache. In this test, each thread involved in an I/O 
operations ends up with one 1MB buffer in its cache.

All combined, it is possible for the hread pool to grow to more than 64 
threads, after which OutOfMemoryError is thrown because the tests limits 
the direct memory to 64MB. To avoid this, the test is changed to use a 
fixed thread pool of 4 threads with the worst case being each thread 
caches up to 8 1MB buffers over the 10k I/O operations that the test 
performs.

The webrev with the changes is here:

http://cr.openjdk.java.net/~alanb/6999915/webrev/

Thanks,

Alan.


More information about the nio-dev mailing list