I have a custom allocator function which uses sbrk() to obtain memory.
How do I release this memory when it’s no longer needed?
Is there a function equivalent to free() for malloc() ?
or do I have to use brk() to set the end of the data segment ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to use
brkorsbrkagain to shrink.In the end the only way you have to modify the amount of memory(apart from mmap like syscalls), is to increase or decrease the heap, so you move it up with
sbrkorbrkand you move it down withbrkorsbrkwith a negative increment.