Wierd behavior of gc.collect
Bodhi
amitdev at gmail.com
Tue Mar 19 12:36:53 EDT 2013
I know this, but my question is what does gc.collect do which results in the c library to free memory? Usually it is because of unreferenced objects in a cycle or something, but here that doesn't seem to be the case.
On Tuesday, March 19, 2013 9:32:27 PM UTC+5:30, Dave Angel wrote:
> On 03/19/2013 11:47 AM, Bodhi wrote:
>
> > I have a python process that does some operations and is supposed to release memory after those. The issue is that memory is not released (as seen through top). So I do a gc.collect() to see if there is any cycle etc. Immediately after doing the collect memory usage drops as expected, but strangely gc.collect() returns 0.
>
> > This means I cannot find out what the problem is by setting the debug option on gc which is what I usually do to figure out issues like this.
>
> >
>
> > Maybe its that my understanding about it is incorrect, but if gc.collect returned 0, how come some memory was freed?
>
> >
>
>
>
> To put it simply, top won't in general show you that things are freed.
>
> The C libraries for malloc and free will reuse the memory, but not
>
> usually release it to the operating system. So it's not usually going
>
> to show up in 'top.'
>
>
>
> There was a long thread on this quite recently, but I can't seem to find
>
> it right now.
>
>
>
>
>
> --
>
> DaveA
More information about the Python-list
mailing list