Garbage Collection 把(java)

想問下有時會就咁建立一個物件,而冇野參考佢,但點解唔會被回收
我睇本書個example 係咁
有個xxx class 係建立個 form
咁佢 new xxx();
整左個form 出黎,但點解唔會被回收既?

唔該

more code please

TOP

原帖由 tonald 於 2009-9-2 15:01 發表
想問下有時會就咁建立一個物件,而冇野參考佢,但點解唔會被回收
我睇本書個example 係咁
有個xxx class 係建立個 form
咁佢 new xxx();
整左個form 出黎,但點解唔會被回收既?

唔該


using java sdk 6 update 14 or above ,then open g1 la

TOP

我講得白d
public class GUI()
{
// Create the gui component
}
new GUI();
咁點解唔會被回收?

TOP

原帖由 tonald 於 2009-9-3 14:04 發表
我講得白d
public class GUI()
{
// Create the gui component
}
new GUI();
咁點解唔會被回收?


why you need garbage collection, by default java sdk is automatically perform garbage collection,so you don't need to care.

try to reuse object la, for example static variable

[ 本帖最後由 xeon0541 於 2009-9-3 14:17 編輯 ]

TOP

see what is singleton pattern la

TOP

JVM performs garbage collection when it wants/needs to do so.  You can call it "lazy" garbage collection.

TOP