Memory SPIKE - Boost ASIO ASYNC read

Wrote a server that simply reads data from the client:

Using boost :: array buffer

Starting the server and system monitor shows 1 MB of use.

1.) Just do async_read_some and do handleRead, in which I call the asyncRead function again.

void asyncRead() {
    m_socket->async_read_some(
        boost::asio::buffer(m_readBuffer, READ_BLOCK_SIZE),
        m_strand->wrap(boost::bind(&ConnectionHandler::handleRead,
                                   shared_from_this(),
                                   boost::asio::placeholders::error,
                                   boost::asio::placeholders::bytes_transferred))
    );
}

and in handleRead I check if there are any errors or not, and if not, I just throw out another asyncRead ().

2.) Failed to send frames (data size of about 102 bytes).

At the end of the test for 10,000 frames. Total send size = 102 * 10000 Total read size = 102 * 10000

But the memory usage in the system monitor increases to 7.8 MB.

. : 1.) - 1. 2.) - . 3.) ioServic, .

. ? boost:: array, . .

+5
1

,

, , async_read_some , READ_BLOCK_SIZE? , async_read.

, , . , (), , , .

boost shared_array. , boost, , , . .

0

All Articles