设为首页 加入收藏

TOP

Garbage Collection
2011-06-09 12:54:45 来源: 作者: 【 】 浏览:576次 评论:0
3)Garbage Collection
State the behavior that is guaranteed by the garbage collection system and write code that explicitly makes objects eligible for collection.
1.    Garbage collection is a mechanism for reclaiming memory from objects that are no longer in use, and making the memory available for new objects.
2.    An object being no longer in use means that it can’t be referenced by any 'active’ part of the program.
3.    Garbage collection runs in a low priority thread. It may kick in when memory is too low. No guarantee.
4.    It’s not possible to force garbage collection. Invoking System.gc may start garbage collection process.
5.    There are no guarantees that the objects no longer in use will be garbage collected and their finalizers executed at all. gc might not even be run if the program execution does not warrant it. Thus any memory allocated during program execution might remain allocated after program termination, unless reclaimed by the OS or by other means.
6.    There are also no guarantees on the order in which the objects will be garbage collected or on the order in which the finalizers are called.
7.    Circular references do not prevent objects from being garbage collected.
8.    We can set the reference variables to null, hinting the gc to garbage collect the objects referred by the variables. Even if we do that, the object may not be gc-ed if it’s attached to a listener. (Typical in case of AWT components) Remember to remove the listener first.
9.    All objects have a finalize method. It is inherited from the Object class.
10.    finalize method is used to release system resources other than memory. (such as file handles and network connections) The order in which finalize methods are called may not reflect the order in which objects are created. Don’t rely on it. This is the signature of the finalize method.
您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇JDBC接口技术 <转> 下一篇CLASS文件的存放位置

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位