Jetty的bytebufferpool模块

bytebufferpool模块用于配置Jetty的ByteBuffer对象的对象池。
通过对象池的方式来管理ByteBuffer对象的使用和生命周期,期望降低Jetty进程内存的使用,同时降低JVM运行期垃圾回收操作的压力。

启用bytebufferpool模块,执行如下命令:

java -jar $JETTY_HOME/start.jar --add-modules=bytebufferpool

命令的输出,如下:

INFO  : bytebufferpool  initialized in ${jetty.base}/start.d/bytebufferpool.ini
INFO  : Base directory was modified

bytebufferpool模块的配置文件$JETTY_BASE/start.d/bytebufferpool.ini,内容如下:

# ---------------------------------------
# Module: bytebufferpool
# Configures the ByteBufferPool used by ServerConnectors.
# The bucket sizes increase linearly.
# Use module "bytebufferpool-quadratic" for a pool that holds more coarse sized buffers.
# ---------------------------------------
--modules=bytebufferpool

## Minimum capacity of a single ByteBuffer.
#jetty.byteBufferPool.minCapacity=0

## Maximum capacity of a single ByteBuffer.
## Requests for ByteBuffers larger than this value results
## in the ByteBuffer being allocated but not pooled.
#jetty.byteBufferPool.maxCapacity=65536

## Bucket capacity factor.
## ByteBuffers are allocated out of buckets that have
## a capacity that is multiple of this factor.
#jetty.byteBufferPool.factor=4096

## Maximum size for each bucket (-1 for unbounded).
#jetty.byteBufferPool.maxBucketSize=-1

## Maximum heap memory held idle by the pool (0 for heuristic, -1 for unlimited).
#jetty.byteBufferPool.maxHeapMemory=0

## Maximum direct memory held idle by the pool (0 for heuristic, -1 for unlimited).
#jetty.byteBufferPool.maxDirectMemory=0

各参数的说明,如下:

  • jetty.byteBufferPool.minCapacity
    单个ByteBuffer对象的最小容量,默认值为0
  • jetty.byteBufferPool.maxCapacity
    单个ByteBuffer对象的最大容量,默认值为65536。当ByteBuffer对象申请的容量超出本值,则创建ByteBuffer对象不会放入池中缓存。
  • jetty.byteBufferPool.factor
    分配内存时的内存块的最小单位。
  • jetty.byteBufferPool.maxBucketSize
    对象池中,单个桶的内存容量的上限。
  • jetty.byteBufferPool.maxHeapMemory
    对象池当前可用的Java堆的内存的容量。
  • jetty.byteBufferPool.maxDirectMemory
    对象池当前可用的堆外内存的容量。
posted @ 2024-03-09 18:22  jackieathome  阅读(20)  评论(0编辑  收藏  举报