本文整理了Java中java.lang.Runtime.runFinalization()
方法的一些代码示例,展示了Runtime.runFinalization()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Runtime.runFinalization()
方法的具体详情如下:
包路径:java.lang.Runtime
类名称:Runtime
方法名:runFinalization
[英]Provides a hint to the VM that it would be useful to attempt to perform any outstanding object finalization.
[中]向VM提供一个提示,提示尝试执行任何未完成的对象终结将非常有用。
代码示例来源:origin: robovm/robovm
/**
* Provides a hint to the VM that it would be useful to attempt
* to perform any outstanding object finalization.
*/
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: osmandapp/Osmand
protected static long runGCUsedMemory() {
Runtime runtime = Runtime.getRuntime();
long usedMem1 = runtime.totalMemory() - runtime.freeMemory();
long usedMem2 = Long.MAX_VALUE;
int cnt = 4;
while (cnt-- >= 0) {
for (int i = 0; (usedMem1 < usedMem2) && (i < 1000); ++i) {
// AVIAN FIXME
runtime.runFinalization();
runtime.gc();
Thread.yield();
usedMem2 = usedMem1;
usedMem1 = runtime.totalMemory() - runtime.freeMemory();
}
}
return usedMem1;
}
代码示例来源:origin: com.h2database/h2
/**
* Call the garbage collection and run finalization. This close all files
* that were not closed, and are no longer referenced.
*/
static void freeMemoryAndFinalize() {
IOUtils.trace("freeMemoryAndFinalize", null, null);
Runtime rt = Runtime.getRuntime();
long mem = rt.freeMemory();
for (int i = 0; i < 16; i++) {
rt.gc();
long now = rt.freeMemory();
rt.runFinalization();
if (now == mem) {
break;
}
mem = now;
}
}
代码示例来源:origin: lealone/Lealone
/**
* Call the garbage collection and run finalization. This close all files
* that were not closed, and are no longer referenced.
*/
static void freeMemoryAndFinalize() {
IOUtils.trace("freeMemoryAndFinalize", null, null);
Runtime rt = Runtime.getRuntime();
long mem = rt.freeMemory();
for (int i = 0; i < 16; i++) {
rt.gc();
long now = rt.freeMemory();
rt.runFinalization();
if (now == mem) {
break;
}
mem = now;
}
}
代码示例来源:origin: robovm/robovm
runFinalization();
代码示例来源:origin: stackoverflow.com
Runtime runtime = Runtime.getRuntime();
for (int i = 0; i < MAX_GC_ITERATIONS; i++) {
runtime.runFinalization();
runtime.gc();
if (getObject() == null)
代码示例来源:origin: psi-probe/psi-probe
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
boolean finalization = ServletRequestUtils.getBooleanParameter(request, "fin", false);
String referer = request.getHeader("Referer");
String redirectUrl;
if (referer != null) {
redirectUrl = referer.replaceAll(replacePattern, "");
} else {
redirectUrl = request.getContextPath() + getViewName();
}
if (finalization) {
Runtime.getRuntime().runFinalization();
logger.debug("Advised finalization");
} else {
Runtime.getRuntime().gc();
logger.debug("Advised Garbage Collection");
}
logger.debug("Redirected to {}", redirectUrl);
return new ModelAndView(new RedirectView(redirectUrl));
}
代码示例来源:origin: geotools/geotools
@BeforeClass
public static void setupOnce() {
// isolate this test from previously run ones that might have left undisposed map contents
System.gc();
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: MobiVM/robovm
/**
* Provides a hint to the VM that it would be useful to attempt
* to perform any outstanding object finalization.
*/
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: ibinti/bugvm
/**
* Provides a hint to the VM that it would be useful to attempt
* to perform any outstanding object finalization.
*/
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Provides a hint to the VM that it would be useful to attempt
* to perform any outstanding object finalization.
*/
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: Audiveris/audiveris
/**
* 'Suggest' to run the garbage collector.
* Note this does not call the garbage collector synchronously.
*/
public static void gc ()
{
rt.runFinalization();
rt.gc();
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Provides a hint to the VM that it would be useful to attempt
* to perform any outstanding object finalization.
*/
public static void runFinalization() {
Runtime.getRuntime().runFinalization();
}
代码示例来源:origin: mercyblitz/thinking-in-spring-boot-samples
public static void main(String[] args) {
Runtime runtime = Runtime.getRuntime();
// 注册 Shutdown Hook
runtime.addShutdownHook(new Thread(() -> {
System.out.println("Shutdown Hook 执行...");
}));
runtime.runFinalization();
System.exit(0);
}
代码示例来源:origin: com.uphyca/android-junit4
private static void stopAllocCounting() {
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
Runtime.getRuntime().gc();
Debug.stopAllocCounting();
}
代码示例来源:origin: com.uphyca/android-junit4
private static void startAllocCounting() {
// Before we start trigger a GC and reset the debug counts. Run the
// finalizers and another GC before starting and stopping the alloc
// counts. This will free up any objects that were just sitting around
// waiting for their finalizers to be run.
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
Runtime.getRuntime().gc();
Debug.resetAllCounts();
// start the counts
Debug.startAllocCounting();
}
代码示例来源:origin: geotools/geotools
grabLogger(Level.SEVERE);
renderAndStop(content, bounds);
Runtime.getRuntime().runFinalization();
String messages = getLogOutput();
assertThat(
代码示例来源:origin: net.sourceforge.owlapi/pellet-core-ignazio1977
private static void _runGC () throws Exception
{
long usedMem1 = usedMemory (), usedMem2 = Long.MAX_VALUE;
for (int i = 0; (usedMem1 < usedMem2) && (i < 500); ++ i)
{
runtime.runFinalization();
runtime.gc();
Thread.yield();
usedMem2 = usedMem1;
usedMem1 = usedMemory();
}
}
代码示例来源:origin: vmware/xenon
public void waitForGC() {
if (!isStressTest()) {
return;
}
for (int k = 0; k < 10; k++) {
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
public void waitForGC() {
if (!isStressTest()) {
return;
}
for (int k = 0; k < 10; k++) {
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
}
}
内容来源于网络,如有侵权,请联系作者删除!