tags:

views:

258

answers:

2

We are creating a Real-Time Process in VxWorks 6.x, and we would like to limit the amount of memory which can be allocated to the heap. How do we do this?

+1  A: 

When creating a RTP via rtpSpawn(), you can specify an environment variable which controls how the heap behaves.
There are 3 environment variables:

HEAP_INITIAL_SIZE - How much heap to allocate initially (defaults to 64K)  
HEAP_MAX_SIZE     - Maximum heap to allocate (defaults to no limit)
HEAP_INCR_SIZE    - memory increment when adding to RTP heap (defaults to 1 virtual page)

The following code shows how to use the environment variables:

   char * envp[] = {"HEAP_INITIAL_SIZE=0x20000", "HEAP_MAX_SIZE=0x100000", NULL);
   rtpSpawn ("myrtp.vxe", NULL, envp, 100, 0x10000, 0, 0);

Benoit
A: 

This can be done through the use of the HEAP_MAX_SIZE environment variable. If it is set, it limits the ability of the heap to grow beyond that size. It does not, however, limit the initial heap size.

See page 31

unwieldy