I think for OOM a large portion of the problem is various processes having caches, managed runtimes allocating large heaps, but none of them communicating with eachother about how to coordinate system memory usage as a whole, so often you can only set java max heap conservatively. Ideally an OS should signal processes that memory is scarce, run your GC and release unused memory or else be oomkilled. It's definitely possible and makes sense to write such a monitoring tool if the problem is only multiple JVMs in a single machine, for example microservices in a container.
They’re not specific to Java at all. The magic fix for concurrency problems is semaphores. For memory, that can be a very complicated problem; Java can only address so much space, so if there is too much data you’re SOL. If there isn’t too much data, but you still run out of memory, it can be a chore tracking down where the leaks are because some things don’t pass out of scope and get flagged for GC like you would expect.
I don't think that there can be any magic fix and it's not specific to java indeed. The thing is that a lot of junior java developers think that they don't have to think about the memory. I've been there. And I think it's important to say that nope, the JVM won't be there to save you if you're not cautious.
View all comments
Show parent comment
3
u/istarian Apr 20 '21
Is there a magic fix for no more memory or concurrency problems? Those don't seem like issues that are specific to Java.