It's not great for everything and neither is Go. You can find a bit more context on that in some of the other threads.
It's not great for everything and neither is Go. You can find a bit more context on that in some of the other threads.
That is changing as we speak:
[1] https://openjdk.org/jeps/8359211
It's coming from Go. In presence of data races on interfaces, slices or maps your memory might get corrupted.
> Also why can't I have my memory back when it's not in use in tightly packed systems?
You can. You have to either set your GC to be more aggressive or you need to utilize value types more.
Regarding the JVM and GC. Good luck with that? Every Java application I've seen in the wild when I supported JVM seemed to never release any ram it allocated. Ever. If it used 1G and even after free, the JVM decided that was going to be used again and wouldn't release it.
It would be hard to sell me on wanting to use Java again (people can pay me enough to do it, but I hate it). Which kinda sucks since Apache Foundation has a ton of really cool projects using it. Kotlin maybe, but I have no real use cases where it would be better than anything else I know right now.
[1] https://openjdk.org/jeps/346
[2] https://openjdk.org/jeps/546
Data races are not common but when they do happen. I hate to debug them. Only thing worse than data races is data races causing SEGFAULTS.
> Every Java application I've seen in the wild when I supported JVM seemed to never release any ram it allocated. Ever.
You can say the same for Go. Nature of GC langs is they consume more memory than what is minimal. And in theory as a trade off they give you memory safety.
Go doesn't even give memory safety. If program is racy enough.
Such as? It's one of the most widely used platform for backend services, basically almost all top 500 company has some business critical infrastructure running Java. It surely can't have "too horrid" problems..
Furthermore, collection time (for moving collectors) is a function of the liveset, not the # of dead objects.
> java -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 test.java
used=7640 MB, committed=7668 MB, max=8192 MB
used=4 MB, committed=20 MB, max=8192 MB
used=3 MB, committed=8 MB, max=8192 MB
used=3 MB, committed=8 MB, max=8192 MB
The RSS drops from ~8GB to 8 MB.