1

I am trying to insert records in cassandra using cassandra-stress tool.

cassandra-stress -d xx.xx.xx.xx -t 500 -c 1 -S 10240000

But I keep running into the following error:

Exception in thread "Thread-159" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
        at java.lang.AbstractStringBuilder.append(Unknown Source)
        at java.lang.StringBuilder.append(Unknown Source)
        at org.apache.cassandra.stress.util.Operation.multiplyString(Operation.java:211)
        at org.apache.cassandra.stress.util.Operation.generateValues(Operation.java:92)
        at org.apache.cassandra.stress.operations.Inserter.run(Inserter.java:45)
        at org.apache.cassandra.stress.StressAction$Consumer.run(StressAction.java:275)

I tried increasing the heap by changing java invocation in /usr/bin/cassandra-stress :

$JAVA -server -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms8033M -Xmx8033M -Xmn400M -cp $CLASSPATH org.apache.cassandra.stress.Stress $@

Please note, cassandra itself is not showing any errors.

I have a quad-core machine with 32 GB running running Ubuntu 12.04.3 LTS(GNU/Linux 3.2.0-55-generic x86_64).

2 Answers 2

1

If you have 32 GB I would try something closer to the amount of memory you have. I would also try a much larger eden size. For a high load system I would use some thing like this.

-Xmn8g -Xmx24g

You can also set the minimum if you like but it might not help.

If you monitor the system with these setting you might find you don't need that much memory and you can reduce it. If this is still too much you need to reduce you stress test or get a bigger box.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply. These settings will increase the usage of physical memory not the java heap. I am monitoring usage using jconsole, and the java heap usage doesn't change.
@BhaskarSinghal These options will significantly change the size of the heap. If you see not change, they haven't been applied correctly. What size of young generation do you see? It should be 8 GB.
Thanks @Peter changing heap size etc didn't work. I just changed the application code to reduce the heap required.
@BhaskarSinghal Reducing the memory requirement is always the best option, though it can be harder if you are using a application outside your control.
0

It really seems to be the case that your heap is inadequate for your usage. So do follow Peter advice. But just in case, you can try to run cassandra-stress with Plumbr, to make sure that it does not leak memory.

1 Comment

Thanks @Nikem changing heap size etc didn't work. I just changed the application code to reduce the heap required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.