4 ms·
> Also, if you're OK with the JVM running at BEAM speeds, you can give it far less memory. I'm curious about this. How do you do it in practice? Doesn't it jus
by rhizome31 8y ago
> Also, if you're OK with the JVM running at BEAM speeds, you can give it far less memory.
I'm curious about this. How do you do it in practice? Doesn't it just crash with OutOfMemory errors when it runs out of memory?
- bad_user 8y agoThe JVM doesn't use more memory than other virtual machines, the problem is that it doesn't release memory back to the operating system, which is why it is being configured with a maximum heap size. Also compacting garbage collectors need more memory available for de-fragmenting the heap. I've been running a simple JVM web app on my own personal server with an allocated 128 MB of RAM and a lot of that is actually unused. You can do a lot with a heap of just 64 MB. People aren't aware, but when running your average PHP app you need more than that with just a couple of requests done at the same time, whereas my JVM server can easily handle 1000 requests per second. Similarly Ruby or Python apps can be big resource hogs, especially when you end up setting up multiple parallel processes. I was also surprised to find that compilation to "native" isn't necessarily efficient in terms of used memory. I've built a similar app in Haskell and the used memory ended up being higher and more unpredictable. If something like Go fares better, it's not because it is compiled to native. All in all the JVM is actually quite efficient in terms of used memory, for a garbage collected language ;-)
- brazzy 8y ago> The JVM doesn't use more memory than other virtual machines, the problem is that it doesn't release memory back to the operating system This is untrue. The default configuration is just to do it very reluctantly, but this can be changed.
- liveoneggs 8y agoI like how you think 64MB is small
- thomascgalvin 8y agoI mean I have 64 gigs of ram on my personal desktop. RAM is cheap, and there are a lot of problems that can be solved by throwing more RAM at it.
- cutler 8y agoConsidering Hetzner (hetzner.com) offer VPSs with 2Gb RAM for 2.99 Euros per month I think it's fair to say we've left the 90s behind as far as RAM is concerned.
- cutler 8y agoI'm intrigued. Was your "simple JVM web app" written in Java? What kind of JVM optimisations were used and do these also apply to Clojure?
- pron 8y agoYou get an OOM if your working set is larger than the heap. Otherwise, the GC just works harder, reducing your performance. Generally, the JVM uses as much memory as you let it.