On 1/23/07, afa654321 <[EMAIL PROTECTED]> wrote:


Is there any limitation on the inital capacity of
"org.apache.mina.common.ByteBuffer"

The following line of code fails with the below-mentioned exceptoin:


int capacity = 2147480000;
org.apache.mina.common.ByteBuffer byteBuffer =
org.apache.mina.common.ByteBuffer.allocate(capacity);

Exception in thread "main" java.lang.IllegalArgumentException: Buffer size
is too big: 2147480000
        at
org.apache.mina.common.PooledByteBufferAllocator.getBufferStackIndex(
PooledByteBufferAllocator.java:227)
        at
org.apache.mina.common.PooledByteBufferAllocator.allocate0(PooledByte
BufferAllocator.java:173)
        at
org.apache.mina.common.PooledByteBufferAllocator.allocate(PooledByteB
ufferAllocator.java:159)
        at org.apache.mina.common.ByteBuffer.allocate(ByteBuffer.java:235)
        at org.apache.mina.common.ByteBuffer.allocate(ByteBuffer.java:215)
        at
org.apache.mina.example.sumup.TestByteBuffer.main(TestByteBuffer.java
:25)

while the same request using NIO ByteBuffer succeeds:

"java.nio.ByteBuffer byteBuffer =  java.nio.ByteBuffer.allocate
(capacity);"

This test was done on a Windows Enterprise 2003 64-bit, MINA Version 1.0.1
,
JDK 5.0


The default buffer allocator pools the buffer, so we thought pooling too big
buffer won't make sense.  If you want to create a bigger buffer, please
change the allocator:

ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to