3 ms·
> The sheer number of String and other lightweight (but existent) instances in a running Java program is astounding, because the language simply doesn't encoura
by titzer 5y ago
> The sheer number of String and other lightweight (but existent) instances in a running Java program is astounding, because the language simply doesn't encourage you to be parsimonious with creating them.
I agree with this. Java promotes a profligate programming style where allocation (and reclamation) are considered free. (They aren't). This is baked into the JDK deeply. E.g. with standard APIs it is not even possible to parse an integer out of a string without allocating memory. Those are language and library design choices that have a huge confounding effect on trying to measure GC.
For example, I wrote the Avrora AVR emulator and sensor network simulator, which is one of the DaCapo benchmarks. It's a CPU emulator for very small devices and uses almost no standard JDK stuff in its core work. As such it allocates very little and has a pretty small heap. It often shows up weird (sometimes obnoxiously small or uninteresting) in papers that study memory management because it really isn't very Java-like in its behavior.
- _old_dude_ 5y ago> with standard APIs it is not even possible to parse an integer out of a string without allocating memory Not true anymore :) https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html#parseInt(java.lang.CharSequence,int,int,int) https://docs.oracle.com/en/java/javase/17/docs/api/java.base...
- titzer 5y agoWonders never cease :)