Reduced memory usage: No additional memory is used to store object metadata, such as flags facilitating synchronization, identity, and garbage collection.
但是這樣的話 value types 要怎麼被 GC 回收?
不過從 jvisualvm1 看起來,通常 java application 比較佔記憶體的大都是 char[], byte[], int[], ...,所以 value types 確實有機會減少記憶體的使用
Primitives do not currently support qualified method calls or field access (i.e. use of the dot operator)
Primitive types 也不能表達 null... 所以還是需要 wrapper class
The Minimal Value Types article goes into great detail on this initial exploratory implementation and although this first cut includes many approximations of the eventual implementation (such as the use of an annotation to denote a value type rather than an express keyword for this purpose), it provides a promising path for the eventual inclusion of value types into Java.
可能需要增加新的 annotation,所以舊的程式沒辦法直接用...
不是已經有 string pool 的概念了嗎?類似的方法套用到 value types 不知可不可行?
value type 就不會在 heap,不需要被 GC (跟 primitive 一樣)
value type 就不會在 heap,不需要被 GC (跟 primitive 一樣)
請問一下,若不是放在 heap 中,那是放在哪裡?
沒有 GC 的話,value type & primitive 佔用的記憶體會被釋放嗎?