Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can anyone shed some light on how/why running the same Java apps in a docker container significantly increased the memory footprint?

Is JVM overhead shared when multiple Java apps are being run on the same machine?



A lot of it is, yes. The JVM loads a large number of largeish class files when it starts; these contain implementations of the standard library and whatever else is on your classpath that you've imported. These have the nice property that they're read-only, though, so multiple JVM processes can safely share them. When you move to sandboxing each JVM off by itself, you lose the ability for them to share memory (which is, in a sense, a _feature_ of sandboxing), so now each of them has to take the 50-100MB hit of those formerly-shared memory regions.

(Note that the huge size of the classes is also the big reason why JVM startup time is so crap; another reason that multitenant JVM systems are great is that every process after the first starts much faster)


Assuming this is referrring to the fact that separate containers will link in separate copies of all the binaries (executable + shared libraries), instead of sharing the pages across all instances of he JVM. There's no way for the kernel to know that they're all the same files. So a lot of code is duplicated.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: