本文整理了Java中java.lang.Runtime.freeMemory()
方法的一些代码示例,展示了Runtime.freeMemory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Runtime.freeMemory()
方法的具体详情如下:
包路径:java.lang.Runtime
类名称:Runtime
方法名:freeMemory
[英]Returns the number of bytes currently available on the heap without expanding the heap. See #totalMemory for the heap's current size. When these bytes are exhausted, the heap may expand. See #maxMemory for that limit.
[中]返回堆上当前可用的字节数,而不展开堆。请参阅#totalMemory以了解堆的当前大小。当这些字节耗尽时,堆可能会扩展。有关该限制,请参见#maxMemory。
代码示例来源:origin: skylot/jadx
public static boolean isFreeMemoryAvailable() {
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long totalFree = runtime.freeMemory() + (maxMemory - runtime.totalMemory());
return totalFree > MIN_FREE_MEMORY;
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap() {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: libgdx/libgdx
@Override
public long getJavaHeap () {
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Status check() {
Runtime runtime = Runtime.getRuntime();
long freeMemory = runtime.freeMemory();
long totalMemory = runtime.totalMemory();
long maxMemory = runtime.maxMemory();
boolean ok = (maxMemory - (totalMemory - freeMemory) > 2048); // Alarm when spare memory < 2M
String msg = "max:" + (maxMemory / 1024 / 1024) + "M,total:"
+ (totalMemory / 1024 / 1024) + "M,used:" + ((totalMemory / 1024 / 1024) - (freeMemory / 1024 / 1024)) + "M,free:" + (freeMemory / 1024 / 1024) + "M";
return new Status(ok ? Status.Level.OK : Status.Level.WARN, msg);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Status check() {
Runtime runtime = Runtime.getRuntime();
long freeMemory = runtime.freeMemory();
long totalMemory = runtime.totalMemory();
long maxMemory = runtime.maxMemory();
boolean ok = (maxMemory - (totalMemory - freeMemory) > 2048); // Alarm when spare memory < 2M
String msg = "max:" + (maxMemory / 1024 / 1024) + "M,total:"
+ (totalMemory / 1024 / 1024) + "M,used:" + ((totalMemory / 1024 / 1024) - (freeMemory / 1024 / 1024)) + "M,free:" + (freeMemory / 1024 / 1024) + "M";
return new Status(ok ? Status.Level.OK : Status.Level.WARN, msg);
}
代码示例来源:origin: skylot/jadx
public void update() {
long used = runtime.totalMemory() - runtime.freeMemory();
int usedKB = (int) (used / 1024);
setValue(usedKB);
setString(String.format(textFormat, (usedKB / TWO_TO_20), maxGB));
if ((used + Utils.MIN_FREE_MEMORY) > runtime.maxMemory()) {
setForeground(RED);
} else {
setForeground(GREEN);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
i++;
if (i % 100000 == 0) {
System.out.println(i + " Total Memory: " + Runtime.getRuntime().totalMemory() + " Free: " + Runtime.getRuntime().freeMemory());
}
if (i < 1000000L) {
inner.schedule(this);
} else {
latch.countDown();
}
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
i++;
if (i % 100000 == 0) {
System.out.println(i + " Total Memory: " + Runtime.getRuntime().totalMemory() + " Free: " + Runtime.getRuntime().freeMemory());
}
if (i < 1000000L) {
inner.schedule(this);
} else {
latch.countDown();
}
}
});
代码示例来源:origin: skylot/jadx
public static String memoryInfo() {
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
return "heap: " + format(allocatedMemory - freeMemory) +
", allocated: " + format(allocatedMemory) +
", free: " + format(freeMemory) +
", total free: " + format(freeMemory + maxMemory - allocatedMemory) +
", max: " + format(maxMemory);
}
内容来源于网络,如有侵权,请联系作者删除!