1.
Objects passed to the method are never garbage collected in that method. So p
cannot be GCed.
x is not an object.
"abc" is a string literal which goes
to the string pool and is not GCed.
So, only a is eligible for GC.
2. 注意方法中的參數是primitive, String ,還是Object
2.1 如是primitive, String 通過方法後,其值不變,因為方法中改變的是方法的行參(只是一個備份而已)
2.2 如是Object ,就要注意方法中的操作是否改變了Object的屬性,這種改變是有效的修改了Object屬性最終值
3
Simply put, there is no guarantee which thread will run when and for how much
time.
In some OSs like Windows, CPU time is given to threads in ratio of
there priority in some OSs like Unix a lower priority thread executes only after
higher priority thread ends.
4
Java does not have a keyword name delete.
An object is only eligible for
garbage collection if the only references to the object are from other objects
that are also eligible for garbage collection. Therefore, if an object obj2 is
eligible for garbage collection and obj1 contains a reference to it, then obj1
must also be eligible for garbage collection.
An object will not necessarily
be garbage collected immediately after the last reference to the object has been
removed. It depends on when the GC thread gets a chance to run. Many a times it
happens that GC doesn't run for the whole life time of the program.
Circular
references generally do not prevent objects from being garbage collected.
An
object is not eligible for garbage collection as long as the object can be
reached from the active part of the program.
An object that has been
eligible for garbage collection may stop being eligible and return to normal
life. This occurs if the call to the finalize() method re-establishes a
reference from the active part of the program to the object.
if an object is resurrected in finalize() then it will never be finalized again.
5.
The Java language does not specify how soon a finalizer will be invoked, except
to say that it will happen before the storage for the object is reused.
Also, the Java language does not specify which thread will invoke the
finalizer for any given object.
If an uncaught exception is thrown during
the finalization, the exception is ignored and finalization of that object
terminates.
3.Garbage Collection
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
1.Declaration And Access Control
miss_yu
2020-07-04 23:29:44
類型轉換(向下強制)
miss_yu
2020-07-04 23:29:44
2.Flow Control, Assertions And Exception Handing
miss_yu
2020-02-24 10:46:14
散列碼(hashcode)
miss_yu
2020-02-24 10:46:14
繼承,抽象,接口之間的關係和區別
miss_yu
2020-02-24 10:46:14
如何理解Spring反向注入?(Spring 之旅)
miss_yu
2020-02-24 10:46:14
9.java.util Package
miss_yu
2020-02-24 10:46:14
Serializable 和 transient 的關係
miss_yu
2018-09-03 19:40:54
4.Language Fundamental
miss_yu
2018-09-03 19:40:54
8.java.lang Package
miss_yu
2018-09-03 19:40:54