sun.misc.Unsafe.freeMemory()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中sun.misc.Unsafe.freeMemory()方法的一些代码示例,展示了Unsafe.freeMemory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.freeMemory()方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:freeMemory

Unsafe.freeMemory介绍

[英]Disposes of a block of native memory, as obtained from #allocateMemory or #reallocateMemory. The address passed to this method may be null, in which case no action is taken.
[中]处理从#allocateMemory或#reallocateMemory获取的本机内存块。传递给此方法的地址可能为null,在这种情况下,不会采取任何操作。

代码示例

代码示例来源:origin: netty/netty

static void freeMemory(long address) {
  UNSAFE.freeMemory(address);
}

代码示例来源:origin: redisson/redisson

static void freeMemory(long address) {
  UNSAFE.freeMemory(address);
}

代码示例来源:origin: apache/ignite

/**
 * Frees memory.
 *
 * @param addr Address.
 */
public static void freeMemory(long addr) {
  UNSAFE.freeMemory(addr);
}

代码示例来源:origin: wildfly/wildfly

static void freeMemory(long address) {
  UNSAFE.freeMemory(address);
}

代码示例来源:origin: redisson/redisson

void free() {
  unsafe.freeMemory(baseAdress);
  MallocBytezAllocator.alloced.addAndGet(-length);
}

代码示例来源:origin: apache/geode

public void freeMemory(long addr) {
 this.unsafe.freeMemory(addr);
}

代码示例来源:origin: RuedigerMoeller/fast-serialization

void free() {
  unsafe.freeMemory(baseAdress);
  MallocBytezAllocator.alloced.addAndGet(-length);
}

代码示例来源:origin: graphhopper/graphhopper

@Override
public void close() {
  super.close();
  UNSAFE.freeMemory(address);
}

代码示例来源:origin: neo4j/neo4j

/**
 * Free the memory that was allocated with {@link #allocateMemory}.
 */
public static void free( long pointer, long bytes )
{
  checkFree( pointer );
  unsafe.freeMemory( pointer );
  GlobalMemoryTracker.INSTANCE.deallocated( bytes );
}

代码示例来源:origin: graphhopper/graphhopper

@Test
  public void testNativeOrder() {
    BitUtil bitUtil = BitUtil.get(ByteOrder.nativeOrder());
    long address = UnsafeDataAccess.UNSAFE.allocateMemory(8);
    long val = 123123123123L * 123L;

    byte[] bytes = new byte[8];
    bitUtil.fromLong(bytes, val);

    if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
      for (int i = 7; i >= 0; i--) {
        UnsafeDataAccess.UNSAFE.putByte(address + i, bytes[i]);
      }
    } else {
      // not tested:
      for (int i = 0; i < 8; i++) {
        UnsafeDataAccess.UNSAFE.putByte(address + i, bytes[i]);
      }
    }

    long tmp = UnsafeDataAccess.UNSAFE.getLong(address);
    assertEquals(val, tmp);
    UnsafeDataAccess.UNSAFE.freeMemory(address);
  }
}

代码示例来源:origin: io.netty/netty-common

static void freeMemory(long address) {
  UNSAFE.freeMemory(address);
}

代码示例来源:origin: facebook/jcommon

unsafe.freeMemory(ptr);

代码示例来源:origin: OpenHFT/Java-Lang

@Override
  public void run() {
    if (address == 0)
      return;
    NativeBytes.UNSAFE.freeMemory(address);
    address = 0;
  }
}

代码示例来源:origin: org.apache.directmemory/directmemory-cache

@Override
public void free()
{
  unsafe.freeMemory( baseAddress );
}

代码示例来源:origin: net.openhft/lang

@Override
  public void run() {
    if (address == 0)
      return;
    NativeBytes.UNSAFE.freeMemory(address);
    address = 0;
  }
}

代码示例来源:origin: io.atomix.catalyst/catalyst-buffer

@Override
@SuppressWarnings("unchecked")
public void free() {
 if (address != 0) {
  NativeMemory.UNSAFE.freeMemory(address);
  address = 0;
 }
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void freeMemory(long address, long size) {
  if (address != 0)
    UNSAFE.freeMemory(address);
  nativeMemoryUsed.addAndGet(-size);
}

代码示例来源:origin: com.truward.tupl/tupl

static void p_delete(final long page) {
  // Only delete pages that were allocated from the Unsafe class and aren't globals.
  if (page != CLOSED_TREE_PAGE && page != EMPTY_TREE_LEAF && !inArena(page)) {
    UNSAFE.freeMemory(page);
  }
}

代码示例来源:origin: pl.edu.icm/JLargeArrays

@Override
  public void run()
  {
    if (ptr != 0) {
      LargeArrayUtils.UNSAFE.freeMemory(ptr);
      ptr = 0;
      MemoryCounter.decreaseCounter(length * sizeof);
    }
  }
}

代码示例来源:origin: com.sleepycat/je

@Override
public int free(long memId) {
  final int totalSize = addOverhead(size(memId) + SIZE_BYTES);
  unsafe.freeMemory(memId);
  usedBytes.addAndGet(0 - totalSize);
  return totalSize;
}

相关文章

Unsafe类方法