Application Memory Exceptions

  • Updated

Issue

After running your application with the Contrast agent, it now runs out of memory.

Cause

The Contrast agent requires a little extra memory in order to operate.

Contrast Protect requires very little, if any, extra memory. Unless you're already very close to the heap limit, it's possible no additions will be necessary. At the maximum, you should add an extra 128MB. The official minimum required for Contrast is 64MB.

Contrast Assess requires more memory to record the analytics necessary to tell a complete vulnerability story. Contrast recommends using 2x the maximum heap usage during typical Assess usage. However the minimum required is 1.3x. (E.g., if you normally run with 128MB of memory, run with 256MB.)

Memory usage with Contrast Assess will be higher in agent versions prior to 3.5.5+.

Resolution

If after adding memory, you're still running out of space, we should generate a heap dump. You can do this a couple different ways:

  1. If you can reliably cause OutOfMemoryErrors to occur, add the following JVM options alongside your -javaagent flag:
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/contrast_dumps/
  2. An alternative way to generate heap dumps is through the jmap command (not available on IBM):
    $ jmap -dump:file=/tmp/contrast_dumps/contrast.hprof,format=b <pid_of_app_server>
    Of course, replace the /tmp/ path with a good place to write. You can then securely send us the heap dump via our secure transfer system. The Contrast Support team will provide a link.
  3. If you have no way of generating heap dumps, we can try to infer where the problem is by using a debug log. You can enable debug logging by adding the following JVM option alongside your -javaagent flag:
    -Dcontrast.level=DEBUG

To contact the Contrast Support Team, please submit a ticket to our online support portal. 

Was this article helpful?

1 out of 2 found this helpful

Have more questions? Submit a request