3 ms·
Isn't JRE using compacting GC which makes the "no copies" guarantee void anyway?
by viraptor 14y ago
Isn't JRE using compacting GC which makes the "no copies" guarantee void anyway?
- TheAnimus 14y agoBeen a while since I've done java, but I'd assume it simply pins it?
- RyanZAG 14y agoThe char or int datatypes do not have their values stored as objects. When you change the value of a char inside a char[] array, that value is directly changed in ram. This will leave the "hello" in ram (subject to GC): String x = "hello" x = null; This will clear the "hello" from ram: char[] x = new char[]{'h','e','l','l','o'}; x[0] = '0'; x[1] = '0'; ... This will leave the "hello" in ram (subject to GC): char[] x = new char[]{'h','e','l','l','o'}; x = null;
- ygra 14y agoThe point was about the garbage collector compacting memory regions, thus moving objects around. If you don't pin your array it could leave "hello" somewhere in memory when it's moved before you zero it.