Database Reference
In-Depth Information
row and key caches in off-heap memory, which means these objects are serialized on a
non-Java heap. That way deserialization will be much faster.
It is recommended to keep heap size moderate, as heap takes memory only from
system memory. It has been observed that it is better to not keep it more than 6 GB (if
system memory is more than 6 GB). You can fetch
maxMemory
by using Java
runtime:
Runtime rTime = Runtime.getRuntime();
long maxSize = rTime.maxMemory();
If system memory is less than 2 GB, it is recommended to keep 50% of it.
Cassandra requires that the Java Native Access (JNA) library be installed for heap
offloading caches.
tps://github.com/twall/jna
and set on the classpath. That's it!
We can also set off-heap memory allocator within
cassandra.yaml
:
memory_allocator: NativeAllocator
possible values are NativeAllocator, JEMallocAllocator.
To install JEMallocAllocator, you need to download and install the jemalloc library.
Source for jemalloc is available over GitHub (
https://github.com/jemal-
loc/jemalloc
).
Installing and Configuring jemalloc
The steps to install jemalloc are
1.
First clone and download the source from github:
git clone
https://github.com/jemalloc/
2.
Change the directory to
jemalloc
and run
configure
:
cd jemalloc
./configure