Any ideas ?
Welcome to Unix. You can only increase the heap size using
sbrk(), you cannot shrink it. So, if you have allocated n
bytes, you can only reuse those bytes, but never give it back
to the system (without terminating the process).
- Sascha
Really?
From
On Wed, Jan 10, 2001 at 09:23:43PM +0200, Stanislav Malyshev wrote:
SS Thanks for the correction! I have never seen that in action
SS though. Usually, the C library will keep freed memory in
SS free lists and does not decrease the size of the data
SS segment using sbrk.
The answer is really not so easy.
I have RedHat Linux 6.2 (with standard kernel, I suppose 2.1).
I tried such program in c++:
//File mall.cc
#include alloc.h
#include stdio.h
#include stdlib.h
#include unistd.h
int main() {
void* v[1000];
for (int i=0;i1000;i++) {