3 ms·
Static memory is at the bottom of the address space, below the heap. But that would really only be relevant in the case of string literals unless I'm mistaken.
by timClicks 9y ago
Static memory is at the bottom of the address space, below the heap. But that would really only be relevant in the case of string literals unless I'm mistaken.
- unwind 9y agoYou can have a static buffer: static char buf[128]; and use strcpy() at any point to copy into it, so I don't think statically allocated strings must be literals.
- stochastic_monk 9y agoThere is a distinction between const and non-const static memory, though, in that the former can be stored in Read-Only Memory. Still, static memory is generally used for many fewer purposes than the stack or the heap, and if I understand correctly, sbrk is still working with the heap, just more manually.
- timClicks 9y agoThat's right. Allocators use the sbrk and mmap to manage the heap. IIRC high performance allocators tend to use mmap exclusively.