本文整理汇总了Java中sun.misc.Cleaner.clean方法的典型用法代码示例。如果您正苦于以下问题:Java Cleaner.clean方法的具体用法?Java Cleaner.clean怎么用?Java Cleaner.clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.misc.Cleaner
的用法示例。
在下文中一共展示了Cleaner.clean方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shutdown
import sun.misc.Cleaner; //导入方法依赖的package包/类
public void shutdown() {
removeMonitoring();
writeQ.clear();
readQ.clear();
inputQueue.clear();
try {
// Cleanup the ByteBuffers only if they are sun.nio.ch.DirectBuffer
// If we don't cleanup then we will leak 16K of memory
if (getRbuf() instanceof DirectBuffer) {
Cleaner cleaner = ((DirectBuffer) getRbuf()).cleaner();
if (cleaner != null) cleaner.clean();
cleaner = ((DirectBuffer) getWbuf()).cleaner();
if (cleaner != null) cleaner.clean();
}
} catch (Throwable t) {
getLogger().error("Exception cleaning ByteBuffer.", t);
}
}
示例2: close
import sun.misc.Cleaner; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
channel.close();
if (PlatformUtil.IS_WINDOWS) {
final Cleaner cleaner = ((DirectBuffer) this.buffer).cleaner();
if (cleaner != null) {
cleaner.clean();
}
}
}
示例3: free
import sun.misc.Cleaner; //导入方法依赖的package包/类
public static void free(ByteBuffer buffer) {
if (buffer.isDirect()) {
Cleaner cleaner = ((DirectBuffer) buffer).cleaner();
if (cleaner != null) {
cleaner.clean();
}
}
}
示例4: clean
import sun.misc.Cleaner; //导入方法依赖的package包/类
private void clean(MappedByteBuffer mapping) {
if (mapping == null) {
return;
}
Cleaner cleaner = ((DirectBuffer) mapping).cleaner();
if (cleaner != null) {
cleaner.clean();
}
}
示例5: freeDirectBuffer
import sun.misc.Cleaner; //导入方法依赖的package包/类
static void freeDirectBuffer(ByteBuffer buffer) {
if (CLEANER_FIELD_OFFSET == -1 || !buffer.isDirect()) {
return;
}
try {
Cleaner cleaner = (Cleaner) PlatformDependent0.getObject(buffer, CLEANER_FIELD_OFFSET);
if (cleaner != null) {
cleaner.clean();
}
} catch (Throwable t) {
// Nothing we can do here.
}
}
示例6: free
import sun.misc.Cleaner; //导入方法依赖的package包/类
@Override
public void free() {
Cleaner cleaner = ((DirectBuffer) buffer).cleaner();
if (cleaner != null)
cleaner.clean();
((MappedMemoryAllocator) allocator).release();
}
示例7: close
import sun.misc.Cleaner; //导入方法依赖的package包/类
public static void close( MappedByteBuffer buffer ) {
try {
if( cleanerField == null ) {
synchronized( Closeables.class ) {
if( cleanerField == null ) init();
}
}
Cleaner cleaner = ( Cleaner ) cleanerField.get( buffer );
cleaner.clean();
} catch( IllegalAccessException e ) {
logger.warn( e.getMessage(), e );
}
}
示例8: freeDirectBuffer
import sun.misc.Cleaner; //导入方法依赖的package包/类
static void freeDirectBuffer(ByteBuffer buffer) {
if (CLEANER_FIELD == null) {
return;
}
try {
Cleaner cleaner = (Cleaner) CLEANER_FIELD.get(buffer);
if (cleaner == null) {
throw new IllegalArgumentException(
"attempted to deallocate the buffer which was allocated via JNIEnv->NewDirectByteBuffer()");
}
cleaner.clean();
} catch (Throwable t) {
// Nothing we can do here.
}
}
示例9: destroy
import sun.misc.Cleaner; //导入方法依赖的package包/类
/**
* Destroys this allocation
*/
void destroy() {
if(block instanceof DirectBuffer) {
Cleaner cleaner = ((DirectBuffer)block).cleaner();
if(cleaner!=null) cleaner.clean();
// leave the accounting for the RefQueue processor
}
}
示例10: deallocate
import sun.misc.Cleaner; //导入方法依赖的package包/类
private void deallocate(ByteBuffer byteBuffer) {
if (byteBuffer == null) {
return;
}
if (byteBuffer instanceof DirectBuffer) {
Cleaner cleaner = ((DirectBuffer) byteBuffer).cleaner();
if (cleaner != null) {
cleaner.clean();
}
}
}
示例11: unmap
import sun.misc.Cleaner; //导入方法依赖的package包/类
private static void unmap(MappedByteBuffer bb) {
Cleaner cl = ((DirectBuffer)bb).cleaner();
if (cl != null)
cl.clean();
}
示例12: unmap
import sun.misc.Cleaner; //导入方法依赖的package包/类
private static void unmap(MappedByteBuffer buffer) {
Cleaner cleaner = ((DirectBuffer) buffer).cleaner();
cleaner.clean(); // If file was memory mapped then windows does not allow to delete it
}
示例13: destroy
import sun.misc.Cleaner; //导入方法依赖的package包/类
@TearDown
public void destroy() throws IOException {
Cleaner cleaner = ((DirectBuffer) memoryMappedSessionState.buffer).cleaner();
cleaner.clean(); // If file was memory mapped then windows does not allow to delete it
Files.deleteIfExists(tempFile);
}