Heap is fully consumed by BouncyCastle objects

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform 6
  • BouncyCastle 1.47

Issue

  • Out of memory errors are seen in JBoss instances.
  • Examining the heap dump shows the majority of memory is consumed by BouncyCastle:
Class Name                                        | Objects | Shallow Heap | Retained Heap
-------------------------------------------------------------------------------------------
org.bouncycastle.jce.provider.BouncyCastleProvider|   5,440 |      522,240 | 1,601,020,200
-------------------------------------------------------------------------------------------

Resolution

Root Cause

Diagnostic Steps

  • Obtained a heap dump from the time of the issue as described in How do I create a Java heap dump?
  • Examined this and discovered a large HashMap of multiple BouncyCastle objects.
Components

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.