Zeroing Memory at Allocation
The memory allocated by malloc or similar C-Runtime functions is not initialized to zero according to the C99 specification, which Windows follows. wRTOS provides a Zero memory on allocation setting in wRTOS Settings.
When this setting is disabled (default), memory requests from some C-Runtime functions or RTAPIs will not be initialized to zero at allocation. However, by definition, memory requests from calloc/_recalloc, VirtualAlloc, and HeapAlloc/HeapReAlloc with the HEAP_ZERO_MEMORY flag will be initialized to zero at allocation.
Note: To improve performance, you should disable this setting once you are sure your processes do not depend on zero memory.
The table below lists the initialization status of the returning memory from various C-Runtime functions and RTAPIs:
| Functions | Zero Memory At Allocation off | Zero Memory At Allocation on |
|---|---|---|
| malloc/new/realloc/_expand | Not zeroed | Zeroed (RTSSRelease configuration only) |
| calloc/_recalloc | Zeroed | Zeroed |
| RtAllocateLocalMemory | Not zeroed | Zeroed |
| RtAllocateLocalMemoryEx without RTALLOC_NOT_ZERO_MEMORY flag | Not zeroed | Zeroed |
| RtAllocateLocalMemoryEx with RTALLOC_NOT_ZERO_MEMORY flag | Not zeroed | Not zeroed |
| HeapAlloc/HeapReAlloc without HEAP_ZERO_MEMORY | Not zeroed | Zeroed |
| HeapAlloc/HeapReAlloc with HEAP_ZERO_MEMORY | Zeroed | Zeroed |
| VirtualAlloc | Zeroed | Zeroed |
| RtAllocateLockedMmeory | Not zeroed | Zeroed |
| RtCreateSharedMemory | Not zeroed | Zeroed |