qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Moravec <pmora...@redhat.com>
Subject Re: receptor out of scope with no calling receptor.close();
Date Tue, 04 Oct 2011 12:35:06 GMT
Hi,
I haven't tested my theory in practise, but if you don't close the receiver, qpid client library
holds some information for all the receivers declared in line:

Receiver receiver = session.createReceiver(address);

and per rough reading source code what the close method performs, I *think* qpid client library
even tries to select the receivers (not valid but not closed) to deliver messages to them.
While the second is just some overhead, the first one (not freeing memory for the receivers)
causes the high memory usage that consequently causes high CPU as well. And as you run the
code in end-less while cycle..

Kind regards,
Pavel


----- Original Message -----
> From: "joseluis" <jleahred@gmail.com>
> To: users@qpid.apache.org
> Sent: Tuesday, October 4, 2011 1:31:48 PM
> Subject: receptor out of scope with no calling receptor.close();
> 
> Hi,
> 
> With other program, I'm sending 1000 messages per second on exchante
> testing/PRD1
> 
> 
> In program bellow, I'm receiving those messages
> The receptor gets out of scope and is created a new one per 1000
> messages
> 
> If line  receptor.close(); is commented, the client program increase
> quickly
> the cpu usage and memory
> 
> If line receptor.close(); is not commented, it works fine
> 
> 
> 
> 
> #include &lt;qpid/messaging/Connection.h&gt;
> #include &lt;qpid/messaging/Message.h&gt;
> #include &lt;qpid/messaging/Receiver.h&gt;
> #include &lt;qpid/messaging/Sender.h&gt;
> #include &lt;qpid/messaging/Session.h&gt;
> 
> #include <iostream>
> 
> 
> 
> using namespace qpid::messaging;
> 
> int main(int /*argc*/, char** /*argv*/) {
>     std::string broker = "127.0.0.1:5672";
> 
>     Connection connection(broker, "");
>     try {
>         connection.open();
> 
>         Session session = connection.createSession();
> 
>         std::string  address =
>                 "testing/PRD1; "
>                 "{ "
>                 "  assert: allways, "
>                 //"  create: never, "
>                 "  node : "
>                 "  { "
>                 "    type: topic "
>                 "  }, "
>                 "  link: "
>                 "  { "
>                 "    durable: false, "
>                 "    x-declare: "
>                 "    { "
>                 "      auto-delete: true, "
>                 "      exclusive: True, "
>                 "      arguments: "
>                 "      { "
>                 "        'qpid.max_count': 1000, "
>                 "        'qpid.max_size': 1000000, "        //  in
>                 bytes
>                 "        'qpid.policy_type': ring "
>                 "      } "
>                 "    } "
>                 "  } "
>                 "} ";
> 
> 
>         int messages_received=1;
>         while(true)
>         {
>             {   //  begin receiver scope. Create receiver on reduced
>             scope
>                 Receiver receiver = session.createReceiver(address);
>                 receiver.setCapacity(100);
>                 while(messages_received % 1000 != 0)       //  every
>                 1000
> messages we will destroy and create a new receiver
>                 {
>                     if(messages_received % 1000)
>                     {
>                         receiver.fetch(Duration::SECOND*1);
>                         ++messages_received;
>                         if(messages_received % 100 == 0)
>                             std::cout << (messages_received/100)%10
>                             <<
> std::flush;
>                     }
>                 }
>                 receiver.close();       //  if commented, the program
> increase cpu and memory
>             }   //  end receiver scope, it will create a new receiver
> instance
>             std::cout << std::endl << "receiver out of scope,
>             creating a new
> one with same configuration" << std::endl;
>             ++messages_received;
>         }
> 
>     } catch(const std::exception& error) {
>         std::cerr << error.what() << std::endl;
>         connection.close();
>         return 1;
>     }
> }
> 
> 
> kind regards
> 
> --
> View this message in context:
> http://apache-qpid-users.2158936.n2.nabble.com/receptor-out-of-scope-with-no-calling-receptor-close-tp6858408p6858408.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
> 
> 

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message