4 ms·
Yes, Java uses a lot of memory. It uses a lot of memory mostly because it doesn't mmap static shared lib files. Most c library based systems (e.g PHP, Python,
by narrator 15y ago
Yes, Java uses a lot of memory. It uses a lot of memory mostly because it doesn't mmap static shared lib files. Most c library based systems (e.g PHP, Python, Ruby) do. When the system can mmap read only shared lib files, that uses a lot less memory because multiple processes can share them and they are only read in to memory as they are accessed thanks to the page fault mechanism of 386 protected-mode architecture.
Java can't do this because Java self-modifies code (JIT) to run faster while it's running. Once all your classes are loaded into ram though, the memory gets consumed at a much more leisurely pace. However, multiple apps can't reuse each other's already mapped into memory code like they can with PHP, etc. As far as appserver restarts, just pay the money for JRebel already and quit complaining. Your life will be so much better.
- t_hozumi 15y agoI cannot understand why JVM sticks to JIT. JIT's advantage is mainly portability of intermediate code. So once intermediate codes are deployed in server, I don't care whether pre-compile takes 30 minutes or not if memory allocation and computation become more efficient. However this might be stupid idea.
- benjiweber 15y agoJIT allows a range of optimisations that are not possible with AOT compilation. A JIT has access to more information at runtime such as profiling data and so can perform more informed optimisations. It can also change over the lifetime of the programme if observations change. Some interesting stuff here http://wikis.sun.com/display/HotSpotInternals/PerformanceTechniques http://wikis.sun.com/display/HotSpotInternals/PerformanceTec...
- deleted 15y ago[deleted]
- t_hozumi 15y agoI see. Thank you for sharing that with me.