How reduce cassandra virtual memory usage?

Cherry picture Cherry · Nov 13, 2014 · Viewed 17.3k times · Source

Is there a settings in cassandra to reduce it memory usage? I understand that cassandra manages memory well, but for testing purposes I do not want to spent 6Gb memory only when cassandra service running on my windows mchine.

UPDATED

I have tired setting disk_access_mode: standart instead of disk_access_mode: auto. It was not help. Also I pay attention that in cassandra 2.0.9 cassandra.yaml file do not contains disk_access_mode by default. So it seems (but I not sure) that disk_access_mode was removed from cassandra.

Answer

Gyuri picture Gyuri · Jan 24, 2017

As @catpaws points out the key is in the documentation at Tuning Java resources and cassandra-env.sh (on my mac I found it in /usr/local/etc/cassandra/cassandra-env.sh) but she falls short of answering the question.

So here is what I did and what happened: I looked at my Activity Monitor and noticed the java (cassandra) memory usage being ~4GB. Then I read the docs and found that the ~4GB is around the same as the allocated heap using the formula

max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)

Then I edited cassandra-env.sh where it says "Override these to set the amount..." and set

MAX_HEAP_SIZE="2GB"

form the original 4GB. I also set

HEAP_NEWSIZE="400M"

but that is not necessary to reduce the memory usage.

I restarted cassandra and checked the Activity Monitor. It said the Memory usage java (cassandra) was now only ~2GB.