4 ms·
If only the JVM could get it's memory usage down.
by vips7L 7y ago
If only the JVM could get it's memory usage down.
- pron 7y agoI think that >75% of people who complain about Java's memory usage don't provide a heap size and use the default, which is asking Java to go ahead and take up up to 25% of RAM whether it really needs to or not. You want to use less RAM? Tell Java to use less RAM.
- pjmlp 7y agoAnd even then, many are just doing bad stuff like using new in loops, iterators in hot loops, and most relevant not actually thinking about their data structures.
- pron 7y agoIterators and other allocations in hot loops are not universally harmful to performance and footprint. Very often they are scalar-replaced (allocated on the stack and reused)-- in fact, if they don't escape, they're almost certain to be. Escape analysis is also now significantly stronger and able to see through abstraction in JDK 14 thanks to increasing the default inlining depth from 9 to 15 (https://bugs.openjdk.java.net/browse/JDK-8234863 https://bugs.openjdk.java.net/browse/JDK-8234863).
- pjmlp 7y agoAgreed, but it depends very much on which JVM one is using, and not all of them offer the same capabilities as Hotspot. And then there is that other special flavour of coffee beans out there.
- vips7L 7y agoPron while I usually agree with you when it comes to criticisms about Java I just can't here. Using 25% of available ram is just not a sane default.
- pron 7y agoBecause it is too high or too low? What would be a sane default? Note that native applications don't have an upper limit at all, but to Java's GCs will be happy to trade available memory for performance.