Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7CE4F7385 for ; Tue, 4 Oct 2011 12:35:35 +0000 (UTC) Received: (qmail 95690 invoked by uid 500); 4 Oct 2011 12:35:35 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 95669 invoked by uid 500); 4 Oct 2011 12:35:35 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 95661 invoked by uid 99); 4 Oct 2011 12:35:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 12:35:35 +0000 X-ASF-Spam-Status: No, hits=-3.7 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,T_FRT_BELOW2,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of pmoravec@redhat.com designates 209.132.183.25 as permitted sender) Received: from [209.132.183.25] (HELO mx4-phx2.redhat.com) (209.132.183.25) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 12:35:28 +0000 Received: from mail02.corp.redhat.com (zmail02.collab.prod.int.phx2.redhat.com [10.5.5.42]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p94CZ6a7025448 for ; Tue, 4 Oct 2011 08:35:06 -0400 Date: Tue, 04 Oct 2011 08:35:06 -0400 (EDT) From: Pavel Moravec To: users@qpid.apache.org Subject: Re: receptor out of scope with no calling receptor.close(); Message-ID: <9dfa803e-69c1-4c96-a2a7-1c57847c3ffc@zmail02.collab.prod.int.phx2.redhat.com> In-Reply-To: <1317727908239-6858408.post@n2.nabble.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Originating-IP: [10.34.1.224] X-Mailer: Zimbra 7.1.2_GA_3268 (ZimbraWebClient - FF3.0 (Linux)/7.1.2_GA_3268) X-Virus-Checked: Checked by ClamAV on apache.org 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" > 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 <qpid/messaging/Connection.h> > #include <qpid/messaging/Message.h> > #include <qpid/messaging/Receiver.h> > #include <qpid/messaging/Sender.h> > #include <qpid/messaging/Session.h> > > #include > > > > 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