How can I get the largest size (continious) in bytes my application can allocate in one malloc
call without returning out of memory
? (biggest available chunk)
P.S.: I would like a general answer for both if I want to allocate it and if I don't want to allocate it (so this question does not need to be reasked).
The following piece of code will provide an approximate answer, especially for real-time deterministic memory allocators found in realtime operating systems. It is not targeted for a general purpose OS: