You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2006/03/12 04:30:59 UTC
svn commit: r385240 -
/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java
Author: trustin
Date: Sat Mar 11 19:30:57 2006
New Revision: 385240
URL: http://svn.apache.org/viewcvs?rev=385240&view=rev
Log:
Updated documentation for PooledByteBufferAllocator
Modified:
directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java?rev=385240&r1=385239&r2=385240&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledByteBufferAllocator.java Sat Mar 11 19:30:57 2006
@@ -36,9 +36,11 @@
* buffer and the capacity you requested are same.
* </p>
* <p>
- * This allocator doesn't deallocate buffers once they are allocated, so the
- * overall memory usage increase as time goes by and cause some applications
- * get {@link OutOfMemoryError} under high load.
+ * This allocator releases the buffers which have not been in use for a certain
+ * period. You can adjust the period by calling {@link #setTimeout(int)}.
+ * The default timeout is 1 minute (60 seconds). To release these buffers
+ * periodically, a daemon thread is started when a new instance of the allocator
+ * is created. You can stop the thread by calling {@link #dispose()}.
* </p>
*
* @author The Apache Directory Project (dev@directory.apache.org)
@@ -78,18 +80,28 @@
private int timeout;
private boolean disposed;
+ /**
+ * Creates a new instance with the default timeout.
+ */
public PooledByteBufferAllocator()
{
this( 60 );
}
-
+
+ /**
+ * Creates a new instance with the specified <tt>timeout</tt>.
+ */
public PooledByteBufferAllocator( int timeout )
{
setTimeout( timeout );
expirer = new Expirer();
expirer.start();
}
-
+
+ /**
+ * Stops the thread which releases unused buffers and make this allocator
+ * unusable from now on.
+ */
public void dispose()
{
if( this == ByteBuffer.getAllocator() )
@@ -121,17 +133,28 @@
}
disposed = true;
}
-
+
+ /**
+ * Returns the timeout value of this allocator in seconds.
+ */
public int getTimeout()
{
return timeout;
}
+ /**
+ * Returns the timeout value of this allocator in milliseconds.
+ */
public long getTimeoutMillis()
{
return timeout * 1000L;
}
+ /**
+ * Sets the timeout value of this allocator in seconds.
+ *
+ * @param timeout <tt>0</tt> or negative value to disable timeout.
+ */
public void setTimeout( int timeout )
{
if( timeout < 0 )