All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gridkit.jvmtool.heapdump.io.HeapPageBufferFactory Maven / Gradle / Ivy

There is a newer version: 0.16
Show newest version
package org.gridkit.jvmtool.heapdump.io;

public class HeapPageBufferFactory implements PagePoolFactory {
    
    private final long memoryLimit;
    private final int allocPageSize;
    
    public HeapPageBufferFactory(int allocPageSize, long memoryLimit) {
        if (Integer.bitCount(allocPageSize) != 1) {
            throw new IllegalArgumentException("allocPageSize " + allocPageSize + " is invalid, should be power of two");
        }
        this.memoryLimit = memoryLimit;
        this.allocPageSize = allocPageSize;
    }

    @Override
    public PagePool createPagePool(int pageSize) {
        if (Integer.bitCount(allocPageSize) != 1) {
            throw new IllegalArgumentException("allocPageSize " + allocPageSize + " is invalid, should be power of two");
        }
        return new ByteBufferPageManager(pageSize, Math.max(pageSize, allocPageSize), memoryLimit);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy