Cassandra generates "java.lang.OutOfMemoryError: Java heap space" on startup

As I upgraded my computer to 13.10, I got errors from Cassandra which seemed strange. That is, Java was failing saying that Cassandra wanted more heap that was made available to it.

I was rather surprised since I had not changed anything in Cassandra. However, thinking about it, the heap offered to Java to run Cassandra is defined as the total amount of RAM available divided by 2. And since I'm running a new kernel, I would imagine that this new kernel uses more RAM. Notice that since the math used is:

Amount of Mb available / 2

If your kernel makes use of another 100Mb to run, you actually remove 50Mb from what was previously made available to Cassandra. I would imagine that such a difference occurred and I was just under the minimum limit that Cassandra generally wants which is around 2Gb.

To fix the problem I did an edit of the configuration file and put 2500Mb as the maximum amount of heap that Cassandra is to use. Such enough, when I start Cassandra with the system monitor on, I can see two jumps of the allocated memory. The first is the 2500Mb and the second is whatever extra Cassandra needs to really full get started.

My change was to edit the JVM_OPTS settings as follow:


Although you could change the MAX_HEAP_SIZE, that would force the minimum amount of memory to be allocated to also be raised (see the line before the -Xmx option), when I only wanted to raise the maximum.

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly