Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Can the JVM put part of the memory on the disk? To reduce the memory occupied by the JVM

Can we put Metaspace on disk? Can the unchanging objects in the method area of the JVM be put into the disk to optimize the memory of the JVM (or objects in the heap that have not been recycled after GC several times). Although the disk IO performance is very low, SSD can greatly improve the performance
Answers
-
This is essentially an o/s kernel issue. It provides a memory API to processes for allocating & freeing memory. The kernel manages memory page swapping as needed - e.g. swapping pages into and out of the memory cash on disk (typically called a page file or swap disk partition).
-
Sorry, I don't quite understand. Do you mean that the operating system can do this, so you don't need a JVM to do it
-
Sorry, I don't quite understand. Do you mean that the operating system can do this, so you don't need a JVM to do it
-
Billy is right, memory swap is an OS task which swaps chunks of memory that belong to different OS processes, including memory allocated for the JVM. OS does not care what exactly this memory is used for, just that it should be swapped when this machine runs out of the physical memory capacity. However, you may offload some of the Java objects from memory through serialisation, thus implementing a kind of swap mechanism on the specific application level. In any case you should also consider performance implications.
-
Sorry, I don't quite understand. Do you mean that the operating system can do this, so you don't need a JVM to do it
The JVM process uses o/s kernel calls for allocating and freeing memory. The o/s manages the physical aspects of the memory pages - whether for example a page can be swapped out, what swap cache to use, and so on.
The process (like JVM) manages the contents of the page via reads and writes - and determine itself when a data structure used is destroyed, whether to release the memory occupied by the structure back to the o/s kernel as free memory, or whether to hang on to that memory for itself to reuse when a new data structure is created.
The o/s kernel can also support huge pages as oppose to tons of little pages. The more pages to manage, the bigger the overhead to manage all these pages, and the slower performance. Fewer pages in turn means the coarser the division of memory is between processes, and the larger the smallest/minimum allocation of memory is.
Then there are means for a process to request pages that will be heavily and continually used, to be locked into memory and not to be swapped,
Memory management is not simplistic. And unfortunately Java can consume lots of memory, made worse by shoddy design and code.
Bottom line is however that more RAM for a device or platform, is invariably A Good Thing (tm).