You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Gregory Mostizky (JIRA)" <ji...@apache.org> on 2008/06/11 12:26:00 UTC

[jira] Created: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Memory leak in broker - Temporary Queue related (fix proposal included)
-----------------------------------------------------------------------

                 Key: AMQ-1790
                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker
    Affects Versions: 5.1.0
         Environment: ActiveMQ broker 5.1 
Spring based application with synchronous messages (temp queue based)
            Reporter: Gregory Mostizky
            Priority: Critical


ActiveMQ broker leaks memory when using temp queues.
This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.

First these are the classes that are leaked:
org.apache.activemq.usage.MemoryUsage
org.apache.activemq.management.PollCountStatisticImpl
org.apache.activemq.usage.DefaultUsageCapacity

Cause:
org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.

Solution:
BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Rob Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rob Davies reassigned AMQ-1790:
-------------------------------

    Assignee: Rob Davies

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Gregory Mostizky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43431#action_43431 ] 

Gregory Mostizky commented on AMQ-1790:
---------------------------------------

Fixed the formating:

{code:title=org.apache.activemq.broker.region.AbstractTempRegion.java|borderStyle=solid}
    protected final synchronized void dispose(ConnectionContext context,
            Destination dest) throws Exception {
        // add to cache
        if (this.doCacheTempDestinations) {
            cachedDestinations.put(new CachedDestination(dest
                    .getActiveMQDestination()), dest);
        } else {
            try {
                dest.dispose(context);
                dest.stop();
            } catch (Exception e) {
                LOG.warn("Failed to dispose of " + dest, e);
            }
        }
    }
{code} 

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Rob Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rob Davies resolved AMQ-1790.
-----------------------------

    Resolution: Fixed

Fixed by svn revision 669511

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Gary Tully (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47145#action_47145 ] 

Gary Tully commented on AMQ-1790:
---------------------------------

N, can you post your test case, how does it compare with http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/advisory/TempQueueMemoryTest.java?view=markup

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Gregory Mostizky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Mostizky reopened AMQ-1790:
-----------------------------------


It turns that there is additional source of memory leak in the above scenario.

Class org.apache.activemq.broker.region.AbstractTempRegion in it's dispose() method doesnt dispose it's destinations when it's running in CacheTempDestinations=false mode (which is default). I fixed the method and used the fixed version on overnight stress test and it so far it seems ok.

The fix (I added the else part):

    protected final synchronized void dispose(ConnectionContext context,
            Destination dest) throws Exception {
        // add to cache
        if (this.doCacheTempDestinations) {
            cachedDestinations.put(new CachedDestination(dest
                    .getActiveMQDestination()), dest);
        } else {
            try {
                dest.dispose(context);
                dest.stop();
            } catch (Exception e) {
                LOG.warn("Failed to dispose of " + dest, e);
            }
        }
    }

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "Rob Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rob Davies resolved AMQ-1790.
-----------------------------

    Fix Version/s: 5.2.0
       Resolution: Fixed

Fixed by SVN revision 666617

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (AMQ-1790) Memory leak in broker - Temporary Queue related (fix proposal included)

Posted by "NNZZ (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-1790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47144#action_47144 ] 

NNZZ commented on AMQ-1790:
---------------------------

Hi there,

I just installed ActiveMQ 5.2, especially for the fix of the above problem, but the above issue is still occurring.

After instantiating circa 1300 temp queues I am getting the following error: java.lang.OutOfMemoryError : unable to create new native thread

Also if I go to the web admin (http://localhost:8161/admin/topics.jsp) I can see a long list of temp queues that don't go anywhere...

Would you be able to advise us when the fix for this issue will be released.

Many thanks

N

> Memory leak in broker - Temporary Queue related (fix proposal included)
> -----------------------------------------------------------------------
>
>                 Key: AMQ-1790
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1790
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.1.0
>         Environment: ActiveMQ broker 5.1 
> Spring based application with synchronous messages (temp queue based)
>            Reporter: Gregory Mostizky
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.2.0
>
>
> ActiveMQ broker leaks memory when using temp queues.
> This is critical for projects that use spring based synchronous messaging because each message creates & destroys new temp queue,
> however because of the leak they are not completely cleaned up resulting in OutOfMemory exception.
> First these are the classes that are leaked:
> org.apache.activemq.usage.MemoryUsage
> org.apache.activemq.management.PollCountStatisticImpl
> org.apache.activemq.usage.DefaultUsageCapacity
> Cause:
> org.apache.activemq.broker.region.BaseDestination is a base class for queues and by extension TempQueues.
> When TempQueue is created it will call BaseDestination constructor which will allocate some memory usage and statistics objects.
> However, the cleanup operation is missing - when TempQueue is destroyed these resources are not removed, and because these objects form a tree with the root being the root SystemUsage object they are never deleted.
> Solution:
> BaseDestination should implement dispose() method - this method is already defined in Destination interface but not implemented in BaseDestination.
> This method should cleanup all the resources allocated during it's creation. For example, see Queue.dispose().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.