|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.red5.server.DebugPooledByteBufferAllocator
public class DebugPooledByteBufferAllocator
A ByteBufferAllocator which pools allocated buffers.
All buffers are allocated with the size of power of 2 (e.g. 16, 32, 64, ...) This means that you cannot simply assume that the actual capacity of the buffer and the capacity you requested are same.
This allocator releases the buffers which have not been in use for a certain
period. You can adjust the period by calling 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 dispose().
| Field Summary | |
|---|---|
protected static ThreadLocal |
local
|
protected static org.slf4j.Logger |
log
Logger |
protected boolean |
saveStacks
Save a stack trace for every buffer allocated? Warning: This slows down the Red5 a lot! |
protected HashMap<org.red5.server.DebugPooledByteBufferAllocator.UnexpandableByteBuffer,StackTraceElement[]> |
stacks
Contains stack traces where buffers were allocated. |
| Constructor Summary | |
|---|---|
DebugPooledByteBufferAllocator()
Creates a new instance with the default timeout. |
|
DebugPooledByteBufferAllocator(boolean saveStacks)
|
|
DebugPooledByteBufferAllocator(int timeout)
Creates a new instance with the specified timeout. |
|
DebugPooledByteBufferAllocator(int timeout,
boolean saveStacks)
|
|
| Method Summary | |
|---|---|
org.apache.mina.common.ByteBuffer |
allocate(int capacity,
boolean direct)
|
void |
dispose()
Stops the thread which releases unused buffers and make this allocator unusable from now on. |
static String |
getCodeSection()
|
int |
getTimeout()
Returns the timeout value of this allocator in seconds. |
long |
getTimeoutMillis()
Returns the timeout value of this allocator in milliseconds. |
void |
printStacks()
|
void |
resetStacks()
|
static void |
setCodeSection(String section)
|
void |
setTimeout(int timeout)
Sets the timeout value of this allocator in seconds. |
org.apache.mina.common.ByteBuffer |
wrap(ByteBuffer nioBuffer)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.slf4j.Logger log
protected static ThreadLocal local
protected HashMap<org.red5.server.DebugPooledByteBufferAllocator.UnexpandableByteBuffer,StackTraceElement[]> stacks
protected boolean saveStacks
| Constructor Detail |
|---|
public DebugPooledByteBufferAllocator()
public DebugPooledByteBufferAllocator(boolean saveStacks)
saveStacks - public DebugPooledByteBufferAllocator(int timeout)
timeout -
public DebugPooledByteBufferAllocator(int timeout,
boolean saveStacks)
timeout - saveStacks - | Method Detail |
|---|
public static void setCodeSection(String section)
section - public static String getCodeSection()
public void dispose()
dispose in interface org.apache.mina.common.ByteBufferAllocatorpublic int getTimeout()
public long getTimeoutMillis()
public void setTimeout(int timeout)
timeout - 0 or negative value to disable timeout.
public org.apache.mina.common.ByteBuffer allocate(int capacity,
boolean direct)
allocate in interface org.apache.mina.common.ByteBufferAllocatorcapacity - direct -
public void resetStacks()
public void printStacks()
public org.apache.mina.common.ByteBuffer wrap(ByteBuffer nioBuffer)
wrap in interface org.apache.mina.common.ByteBufferAllocatornioBuffer -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||