- Mastering High Performance with Kotlin
- Igor Kucherenko
- 174字
- 2021-06-25 20:55:22
Heap fragmentation
When the JVM starts, it allocates heap memory from the operating system and then manages that memory. Whenever an application creates a new object, the JVM automatically allocates a block of memory with a size that's big enough to fit the new object on the heap. After sweeping, in most cases, memory becomes fragmented. Memory fragmentation leads to two problems:
- Allocation operations become more time consuming, because it's hard to find the next free block of sufficient size
- The unused space between blocks can become so great that the JVM won't be able to create a new object
The following diagram illustrates a fragmented memory heap:

To avoid these problems after each GC cycle, the JVM executes a compaction step. Compacting moves all reachable objects to one end of the heap and, in this way, closes all holes. The heap after compacting looks as follows:

These diagrams show how blocks are located before and after compacting. The drawback is that an application must also be suspended during this process.
- Learning Data Mining with R
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- Python Web數據分析可視化:基于Django框架的開發實戰
- ElasticSearch Cookbook(Second Edition)
- 軟件體系結構
- Windows Phone 8 Game Development
- Modernizing Legacy Applications in PHP
- 黑莓(BlackBerry)開發從入門到精通
- Python機器學習與量化投資
- Scrapy網絡爬蟲實戰
- FusionCharts Beginner’s Guide:The Official Guide for FusionCharts Suite
- 程序員面試金典(第6版)
- AI輔助編程Python實戰:基于GitHub Copilot和ChatGPT
- Python程序員面試算法寶典
- Learning SaltStack(Second Edition)