This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Re: Problems with releasing memory for the "vector"!
- From: "Mr. H. Xia" <h dot xia at sheffield dot ac dot uk>
- To: "Christopher Jefferson" <caj at cs dot york dot ac dot uk>
- Cc: "libstdc++ " <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 20 Apr 2005 16:36:34 +0100
- Subject: Re: Re: Problems with releasing memory for the "vector"!
======= At 2005-04-20, 11:36:55 you wrote: =======
>This is just how memory allocation works.. the memory is kept in an
>internal cache, so it can be given back out without having to go and ask
>the operating system for some more memory.
>
>Try altering your program to have the code in main twice. I did this,
>and got this output:
>
> RSS VSZ %MEM COMMAND
>121780 156868 15.5 ./a.out
>Before clear --------------------------
> RSS VSZ %MEM COMMAND
>109552 144708 13.9 ./a.out
>After clear ---------------------------
> RSS VSZ %MEM COMMAND
>121840 156996 15.5 ./a.out
>Before clear --------------------------
> RSS VSZ %MEM COMMAND
>109552 144708 13.9 ./a.out
>After clear ---------------------------
>
>as you can see, modulo some very small differences, the memory is being
>reused the second time through.
Yeah, I also tried this. It seems not predictable. In my test, the odd call on tryclean() doesn't clean, while the even call does.
And on Redhat 7.3 with glibc-2.2.5-34 & gcc 2.96, it's cleaned everytime as well as with MinGW & gcc 3.2.3 on MS windows.
Does it mean not to give the control of releasing memory to the programmer is the future? Okay, you want to release memory? You have to quit.
>
>I'm unsure if it is possible to force the memory to be released back to
>the operating system, and how useful such a thing would be anyway...
The code I am working on involves massive scientific computation. It's not like just writing an email client program or something. Exceeding the 2GB limit is very usual, so I am trying to minimize the memory usage as possible as I can.
Reuse?
Unfortunately, some temporary data has to be released, because later data may not have the same type and size and therefore cannot fully ultilize the uncleaned memory thoroughly.
Thanks Chris.
Hao