Issue Details (XML | Word | Printable)

Key: AMQ-1681
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Hiram Chirino
Reporter: Gregory Mostizky
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ActiveMQ

Memory leak when creating large numbers of TemporaryQueues (Log4J related)

Created: 23/Apr/08 04:19 AM   Updated: 24/Apr/08 08:59 AM
Return to search
Component/s: Broker
Affects Version/s: 5.0.0
Fix Version/s: 5.1.0

Time Tracking:
Not Specified

Environment: Embedded broker using Log4J


 Description  « Hide
When using an embedded broker and using Log4J, there is a memory leak in the broker for each new TemporaryQueue created.

This seems to be the offending code (taken from 5.0.0-release source):

org.apache.activemq.broker.region.Queue:

public Queue(Broker broker, ActiveMQDestination destination, final SystemUsage systemUsage, MessageStore store, DestinationStatistics parentStats,
TaskRunnerFactory taskFactory, Store tmpStore) throws Exception { ... skipped.... // let's copy the enabled property from the parent DestinationStatistics this.destinationStatistics.setEnabled(parentStats.isEnabled()); destinationStatistics.setParent(parentStats); this.log = LogFactory.getLog(getClass().getName() + "." + destination.getPhysicalName()); }

What happens here is that for each new TemporaryQueue created a new log instance is created with rather large string as it's name.
This instance is unique for each new TemoraryQueue and because of the way Log4J handles those instances, it is never removed once initalized.

We hit this bug when we were testing performance together with Spring-based synchronous JMS API, which is implemented in such a way that
for each new message it creates a new TemporaryQueue. We got OutOfMemory after about 40000 messages with 128M heap.

I am not sure what this special log instance is used for, but assuming it's not very important, it will be easy to fix this bug with just using some predefined log name always.



 All   Comments   Work Log   Change History   Subversion Commits   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Hiram Chirino added a comment - 24/Apr/08 08:59 AM
This also occurred with temp topics.

Fixed in revision 651300