Setting the Maximum Buffer Limit

This tutorial describes how to set the maximum buffer limit.

Purpose

The purpose of this tutorial is to show you how to set the maximum size for the metadata buffer.

Required Background

The Metadata Utility Library Overview introduces the metadata client utility.

Introduction

The client can control the size of the metadata buffer by setting a maximum buffer limit. Setting the maximum buffer limit enables the client to restrict metadata buffer usage, thus ensuring it has sufficient heap for other tasks. Once this limit has been set, it is then the parser’s responsibility to stop appending metadata field items once the buffer reaches this upper limit. If the client does not set a limit, then the parser appends metadata field items until it uses the complete heap in the client thread.

The client should set the limit to an optimized value based on the following factors:

  • the heap allocated to the thread

  • the number of parsers

  • the number of buffers used at a time.

Using Metadata Buffer

The following tasks will be covered in this tutorial:

  • Set the maximum buffer limit

Basic Procedure

The high level steps to set the maximum buffer limit are shown here:

  1. Create a new metadata utility object.

  2. Initialise a parser plug-in with an input source.

  3. Call CMetaDataClientUtility::SetMetaDataBufferLimitL() and set aMaxBufferSize to the maximum buffer size.

    IMPORT_C void SetMetaDataBufferLimitL(TInt aMaxBufferSize);

    Note: Maximum buffer size must be greater than zero, otherwise it leaves with KErrArgument.

Example

//Create a new utility object (utility)
//Initialise the parser plug-in

utility->SetMetaDataBufferLimitL(100) //Set the max buffer limit to 100