Limit the size of queues
In various parts of Openfire, queues are in use to (temporarily) store data (often Packets). If a bug is introduced where those queues aren't emptied, a memory leak occurs.
Queues should all get a defined capacity, smaller than the maximum integer value. The capacity should be set in such a way that it will not be reached under extreme, but valid circumstances.
If a queue reaches capacity (runtime) exceptions will be thrown and logged, which will make the source of the problem very visible.
Most of the BlockingQueues in use have now been capped at 10,000 elements.