Search code examples
vxworks

How can I specify the maximum amount of heap an RTP can use in VxWorks?


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?


Solution

  • 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);