activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonnyamq <blog4mrander...@yahoo.com>
Subject Memory Usage of activeMQ CPP
Date Thu, 28 Feb 2013 23:49:04 GMT
Test code (pretty much stripped down version of example):

int main(int argc, char* argv[] ) {

    activemq::library::ActiveMQCPP::initializeLibrary();
    {
    Connection* connection;
    std::cout << "=====================================================\n";
    std::cout << "Starting the initialized:" << std::endl;
    std::cout << "-----------------------------------------------------\n";

    std::string brokerURI =
        "failover:(tcp://localhost:61616"
//        "?wireFormat=openwire"
//        "&transport.useInactivityMonitor=false"
//        "&connection.alwaysSyncSend=true"
//        "&connection.useAsyncSend=true"
//        "?transport.commandTracingEnabled=true"
//        "&transport.tcpTracingEnabled=true"
//        "&wireFormat.tightEncodingEnabled=true"
        ")";


    std::cout << "connect...:" << std::endl;
     try {

            // Create a ConnectionFactory
            auto_ptr<ConnectionFactory> connectionFactory(
                ConnectionFactory::createCMSConnectionFactory(brokerURI));

            // Create a Connection
            connection = connectionFactory->createConnection();
            // connection->start();

     } catch (CMSException& e) {
            e.printStackTrace();
     }
    std::cout << "connected...:" << std::endl;
    sleep(10);
    std::cout << "cleanup...:" << std::endl;

        if (connection != NULL) {
            try {
                connection->close();
            } catch (cms::CMSException& ex) {
                ex.printStackTrace();
            }
        }

        // Destroy resources.
        try {
            delete connection;
            connection = NULL;
        } catch (CMSException& e) {
            e.printStackTrace();
        }
    std::cout << "-----------------------------------------------------\n";
    std::cout << "Finished with the example." << std::endl;
    std::cout << "=====================================================\n";

    }
    activemq::library::ActiveMQCPP::shutdownLibrary();

}



Looking at the memory usage in "top" 

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 6413 root      20   0  *498m* 5360 3848 S  0.0  0.3   0:00.00 test


VIRT memory jumps to nearly 500MB! Why? Is there something that can be done
to keep this memory about the same as RES portion (which is about 5K and is
probably appropriate for a program that does nothing, like the one above).

If I comment out  
connection = connectionFactory->createConnection();

memory drops down to acceptable levels (like 50K).  
Memory is a constraint for me and this behavior seems wrong. As a comparison
sshd runs happily with <100K of VIRT memory.... ActiveMQ-CPP should too -
right?




--
View this message in context: http://activemq.2283324.n4.nabble.com/Memory-Usage-of-activeMQ-CPP-tp4664276.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message