equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Sun designates this |
7 * published by the Free Software Foundation. Sun designates this |
29 import java.lang.reflect.*; |
29 import java.lang.reflect.*; |
30 import java.io.IOException; |
30 import java.io.IOException; |
31 import java.nio.ByteBuffer; |
31 import java.nio.ByteBuffer; |
32 import java.nio.MappedByteBuffer; |
32 import java.nio.MappedByteBuffer; |
33 import java.nio.channels.*; |
33 import java.nio.channels.*; |
34 import java.nio.channels.spi.*; |
|
35 import java.security.AccessController; |
34 import java.security.AccessController; |
36 import java.security.PrivilegedAction; |
35 import java.security.PrivilegedAction; |
37 import java.util.*; |
36 import java.util.*; |
38 import sun.misc.Unsafe; |
37 import sun.misc.Unsafe; |
39 import sun.misc.Cleaner; |
38 import sun.misc.Cleaner; |
98 if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) { |
97 if ((inCacheBuf == null) || (buf.capacity() > inCacheBuf.capacity())) { |
99 bufferPool[i].set(new SoftReference<ByteBuffer>(buf)); |
98 bufferPool[i].set(new SoftReference<ByteBuffer>(buf)); |
100 return; |
99 return; |
101 } |
100 } |
102 } |
101 } |
|
102 |
|
103 // release memory |
|
104 ((DirectBuffer)buf).cleaner().clean(); |
103 } |
105 } |
104 |
106 |
105 private static class SelectorWrapper { |
107 private static class SelectorWrapper { |
106 private Selector sel; |
108 private Selector sel; |
107 private SelectorWrapper (Selector sel) { |
109 private SelectorWrapper (Selector sel) { |