Java: Memory

wuchangjian2021-10-31 07:03:46编程学习

Garbage Collection

In Java, the memory created on the heap is released by the garbage collector. When no references to an object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed. There is no explicit need to destroy objects as in C++. Garbage collection only occurs sporadically (if at all) during the execution of your program. It will not occur simply because one or more objects exist that are no longer used.

Garbage Collection On Demand

If instead of running garbage collector sporadically, you want to invoke the mechanism yourself you can do --

    Runtime r = Runtime.getRuntime();
    r.gc(); // request garbage collection
    r.freeMemory(); // get baseline memory usage.

相关文章

格式化时间

// 格式化时间 public formatDate(time: any, fmt?...

Python教程:在python中对列表进行排序详解

Python教程:在python中对列表进行排序详解

欢迎你来到站长在线的站长学堂学习Python知识,本文学习的是《在Pyth...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。