Home |
RTKernel-32 Programming Manual Multitasking, Real-Time, and RTKernel-32 Alternate APIs for RTKernel-32 Driver MEMSTH Preconfigured Driver Library Drvrt32.lib |
Driver MEMSTHMEMSTH (STatic Heap) is implemented using a statically allocated uninitialized array in the program's data segment. The size of this heap is fixed and must be set at compile time. The default size is 2048 bytes. To change it, include the following statements in your program: #define STHEAPSIZE (2*1024) char MEMSTHeapData[STHEAPSIZE] = {0}; DWORD MEMSTHeapDataSize = STHEAPSIZE; and adjust STHEAPSIZE to the desired value. The static heap uses a semaphore to protect against recursive calls. The allocation strategy is "best fit" and will frequently use memory more efficiently than malloc. Allocations are supported even before the C/C++ run-time system is completely initialized. To enquire the current state of the static heap, function MEMSTHeapInfo can be called: typedef struct { DWORD TotalFree, // available memory TotalUsed, // total allocated memory FreeBlocks, // number of free blocks UsedBlocks, // number of allocated blocks LargestFree; // largest free block } MEMSTHeapInfoRec; void RTKAPI MEMSTHeapInfo(MEMSTHeapInfoRec * Info); These declarations are also contained in header file Stheap.h. Requirements: none.
|