Memory Metrics

This topic describes the metrics provided by a Comms pond.

A Comms pond creates and manages pools of Comms buffers (MBufs). Each pool contain buffers of a specified size. The pond provides information about the size of these buffers and the memory utilisation of the pools.

Metric method Description

RCommsBufPond::NextBufSize()

Returns the next MBuf size that is strictly larger than the specified parameter, or KErrNotFound if there is no pool with larger buffers. The return value is independent from the number of free buffers of that size.

To obtain the first size, pass 0 as the parameter.

RCommsBufPond::LargestBufSize()

Returns the largest buffer size in the pond. The return value is independent from the amount of free buffers in the largest-size pool.

RCommsBufPond::BytesAvailable()

Returns the sum of the amount of available memory in all the pools.

RCommsBufPond::BytesAvailable(TInt aSize)

Returns the amount of available memory in the first pool of the specified buffer size. To get the number of free buffers in the pool, divide the return value by the buffer size.

To get the list of the existing buffer sizes, call NextBufSize() as in the following example:


RMBufAllocator allocator;

TInt size = 0;

do 
    {
    // Get the next size
    size = allocator.NextBufSize(size);
            
                // error 
    if(size <0)
        {
        // no pool of bigger buffers, or error: end iteration
        break;
        }
    RDebug::Printf(ā€œ%dā€,size);
    }
while(true);

Note that the example uses a RMBufAllocator object instead of the pond: this optimisation is explained in the TLS Look-up Reduction Tutorial.

Related tasks
Allocation tutorial