[ 
https://issues.apache.org/jira/browse/AMQ-4715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13763477#comment-13763477
 ] 

Jaromir Hamala commented on AMQ-4715:
-------------------------------------

ritesh, it's not a bug. 
It is a perfectly normal behavior of Java Virtual Machine. Unused memory might 
or might not be reclaimed back to the operating system. When and if the memory 
will be reclaimed back depends on number of factors (JVM configuration, etc). 
Here is a brief explanation how JVM maintains memory: 
http://pubs.vmware.com/vfabric52/index.jsp?topic=/com.vmware.vfabric.em4j.1.2/em4j/conf-heap-management.html

I'm not sure whether this is a right place discuss this as it's not ActiveMQ 
issue. I believe you might get better answers in dedicated Q&A forums such as 
http://stackoverflow.com/ .
                
> Memory issue with ActiveMQ in java
> ----------------------------------
>
>                 Key: AMQ-4715
>                 URL: https://issues.apache.org/jira/browse/AMQ-4715
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.6.0, 5.7.0
>            Reporter: ritesh
>
> Every time when i start connection and create session i can see “java.exe” 
> (in task manger) memory get increase by 1000 to 2000K that’s ok.
> Now, when i closed connection and session expecting to memory  go down by 
> 1000 to 2000K but nothing happening.
> Here is my sample code.
> {code}
> public static void main(String[] args) {
>   try {
>     ActiveMQConnectionFactory connectionFactory = new 
> ActiveMQConnectionFactory("tcp://localhost:61616");
>     Connection connection= connectionFactory.createConnection();
>     connection.start();          
>     for(int i=0;i<40;i++) {
>       Session session=  m_connection.createSession(false, 
> Session.CLIENT_ACKNOWLEDGE);
>       Destination queueDestination = session.createQueue("TestQueue");
>       MessageProducer producer = session.createProducer(queueDestination);
>       producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>       TextMessage textMessage = session.createTextMessage();
>       textMessage.setText(“some text”);
>       String jmsCorrelationId= UUID.randomUUID().toString();
>       textMessage.setJMSCorrelationID(m_jmsCorrelationId);
>       producer.send(textMessage);
>       if (producer != null) {
>          producer.close();
>          producer=null;
>       }
>       
>       if(m_session != null) {
>         session.close();
>         session=null;
>       }
>     } // end for loop
>     if (connection!=null) {
>       connection.close();
>     }
>   }
> }
> {code}
> If you will execute this program three to four times you will see significant 
> memory get increase in task manger for “java.exe”.
> Thing most bothering me is that… after executing this program all allocated 
> memory should get cleaned-up by GC but look like somehow it’s not happening.
> No idea what am I doing wrong?
> Please help me!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to