Afgeronde rechthoek: Top of book Afgeronde rechthoek: Managers track Afgeronde rechthoek: Technical track Afgeronde rechthoek: Previous page Afgeronde rechthoek: Home
 

 

 

 


Memory management

If the memory requirements of the instances are precisely known, then it becomes possible to implement a memory manager that is in full control of garbage collection. The component supplier must state the number and the size of the dynamically memory blocks that will maximally be used by an instance of the component class. Dynamic allocation and deletion of instances will completely be controlled by the infrastructure. There is no need for the component supplier to care about this part of the memory handling. However, if an instance wants to dynamically allocate a memory block, then it must do this via a special call to the memory manager.

void *newMemPtr =

TheMemoryManagerPtr->GetMemoryBlock( theLocalMCClaimDataPtr, index);

A corresponding memory block release can be activated by:

TheMemoryManagerPtr->FreeMemoryBlock( theLocalMCClaimDataPtr, index);

‘TheMemoryManagerPtr’ stands for a pointer to the memory manager, which is part of the infrastructure. ‘theLocalMCClaimDataPtr’ stands for a pointer to a local attribute that contains the data of the local placeholders for pointers to allocated memory. ‘index’ is an index in the array of local storage pointers for a given allocation size. Each instance has its own set of attributes that administrate or hold dynamically allocated memory. For each allocation-size exists at least one pair of supporting attributes. One attribute of the pair holds the administration data. The other holds the storage pointers. (Only the first attribute adds to the overhead of this service.)

The programmer that wants to allocate dynamic space for a local C++ class must use a special version of ‘operator new’. This operator also uses an index and a pointer to a local attribute that contains the data of the local placeholders for pointers to allocated memory. Thus allocating a C++ class looks like:

MyClass *pExample =

new( theLocalMCClaimDataPtr, index) MyClass();

This ‘operator new’ version corresponds to an ‘operator delete’:

delete(theLocalMCClaimDataPtr, index) pExample;

By using these utilities, the memory manager can keep full control. If a task is stopped, then the memory manager takes care of the necessary cleanup actions.

The component designer has no notion how many instances of his class will be used in a given instant. He also does not know whether these instances are fixed or that they are created dynamically. The system architect delivers the necessary extra information indirectly by specifying the connection schemes that are used in the system modes of the target product.

 

 

Afgeronde rechthoek: Top of page Afgeronde rechthoek: Next page