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

馋奶兔 提交于 2019-12-11 01:30:02

问题


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:


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




回答2:


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



来源:https://stackoverflow.com/questions/89866/how-can-i-specify-the-maximum-amount-of-heap-an-rtp-can-use-in-vxworks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!