5 ms·
Agreed, however there is also a reason why the best ones also pack multiple GC algorithms, like in Java and .NET, because one approach doesn't fit all workloads
by pjmlp 8mo ago
Agreed, however there is also a reason why the best ones also pack multiple GC algorithms, like in Java and .NET, because one approach doesn't fit all workloads.
- nevdka 8mo agoThen there’s perl, which doesn’t free at all.
- cermicelli 8mo agoFreedom is overrated... :P
- NooneAtAll3 8mo agodoesn't java also? I heard that was a common complaint for minecraft
- xxs 8mo agoWhat do you mean - if Java returns memory to the OS? Which one - Java heap of the malloc/free by the JVM?
- cogman10 8mo agoJava is pretty greedy with the memory it claims. Especially historically it was pretty hard to get the JVM to release memory back to the OS. To an outsider, that looks like the JVM heap just steadily growing, which is easy to mistake for a memory leak.
- xxs 8mo agoJava has a quite strict max heap setting, it's very uncommon to let it allocate up to 25% of the system memory (the default). It won't grow past that point, though. Baring bugs/native leaks - Java has a very predictable memory allocation.
- NooneAtAll3 8mo agowe aren't talking about allocation, tho we are talking about DEallocation
- xxs 8mo agoit's a reply to: "To an outsider, that looks like the JVM heap just steadily growing, which is easy to mistake for a memory leak." I cut the part that it's possible to make JVM return memory heap after compaction but usually it's not done, i.e. if something grew once, it's likely to do it again.
- k_roy 8mo ago> Especially historically it was pretty hard to get the JVM to release memory back to the OS. This feels like a huge understatement. I still have some PTSD around when I did Java professionally between like 2005 and 2014. The early part of that was particularly horrible.
- adgjlsfhk1 8mo agoThis only really ends up being a problem on windows. On systems with proper virtual memory setups, the cost of unused memory is very low (since the the OS can just page it out)
- snackbroken 8mo agoFor video games it is pretty bad, because reading back a page from disk containing "freed" (from the application perspective, but not returned to the OS) junk you don't care about is significantly slower than the OS just handing you a fresh one. A 10-20ms delay is a noticeable stutter and even on an SSD that's only a handful of round-trips.
- cogman10 8mo agoGames today should be using ZGC. There's a lot of bad tuning guides for minecraft that should be completely ignored and thrown in the trash. The only GC setting you need for it is `-XX:+UseZGC` For example, a number of the minecraft golden guides I've seen will suggest things like setting pause targets but also survivor space sizes. The thing is, the pause target is disabled when you start playing with survivor space sizes.
- xxs 8mo agoOverall if java hits the swap, it's a bad case. Windows is a like special beast when it comes to 'swapping', even if you don't truly needed it. On linux all (server) services run with swapoff.
- cogman10 8mo agoUnfortunately, the JVM and collectors like the JVM's plays really bad with virtual memory. (Actually, G1 might play better. Everything else does not). The issue is that through the standard course of a JVM application running, every allocated page will ultimately be touched. The JVM fills up new gen, runs a minor collection, moves old objects to old gen, and continues until old gen gets filled. When old gen is filled, a major collection is triggered and all the live objects get moved around in memory. This natural action of the JVM means you'll see a sawtooth of used memory in a properly running JVM where the peak of the sawtooth occasionally hits the memory maximum, which in turn causes the used memory to plummet.
- adgjlsfhk1 8mo agoMinecraft for somewhat silly reasons was largely stuck using Java8 for ~a decade longer than it should have which meant that it was using some fairly outdated GC algorithms.
- NooneAtAll3 8mo ago"silly reasons" being Java breaking backwards compatibility decade seems a usual timescale for that, considering f.e. python 2->3
- kbolino 8mo agoSo much software was stuck on Java 8 and for so long that some of the better GC algorithms got backported to it.
- hedora 8mo agoPerl frees memory. It uses refcounting, so you need to break heap cycles or it will leak. (99% of the time, I find this less problematic than Java’s approach, fwiw).
- wredcoll 8mo agoUnless this has changed recently, perl doesn't free memory to the kernel, only within its own process/vm.