12 Kasım 2021 Cuma

java komutu Off-heap İçin -X Seçenekleri

Giriş
Açıklaması şöyle. Off-heap yerine bazen "Direct Memory" de kullanılıyor.
Any memory the JVM uses besides the heap is considered off-heap. 
Off-heap bellek dışında iki bellek daha var. Bunlar
1. Direct Buffer
2. Native Memory allocations through JNI

Direct Memory vs Direct Buffer
 "Direct Memory" ve "Direct Buffer" farklı şeylerdir. Direct Buffer genelde low level I/O için kullanılır

Açıklaması şöyle
Even though the JVM does not track its direct byte buffer memory usage by default, we can measure these buffers’ sizes using a trick involving the DirectByteBuffer class. This class stores the location and size of a single direct byte buffer, so if we sum the size field of all DirectByteBuffer instances we’ll end up with our answer. There are some technicalities though. Firstly, some DirectByteBuffer instances may point at the physical memory owned by other instances (called “viewed” buffers). Secondly, DirectByteBuffer instances whose backing memory is likely already deallocated may still be around (“phantomed” or “phantom-reachable” buffers).

Luckily, there are some tools around to deal with these problems. For instance, IBM’s Eclipse Memory Analyzer extensions have a feature to calculate the size of non-viewed non-phantomed direct byte buffers.
Native Memory allocations through JNI

Off-heap İçin -X Seçenekleri

-XX:MaxDirectMemorySize seçeneği
JVM'in ne kadar "native" bellek alanı kullanabileceğini belirtir. Açıklaması şöyle.
The internal JVM limit is set as follows:

By default, it’s equal to  -Xmx. Yes, the JVM heap and off-heap memory are two different memory areas, but by default, they have the same maximum size.

The limit can be changed using -XX:MaxDirectMemorySize  property. This property accepts acronyms like “g” or “G” for gigabytes, etc.
XX:NativeMemoryTracking seçeneği

Hiç yorum yok:

Yorum Gönder