Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41536

Re: Wierd behavior of gc.collect

Date 2013-03-19 13:13 -0400
From Dave Angel <davea@davea.name>
Subject Re: Wierd behavior of gc.collect
References <76cc4613-8086-4b36-a8bd-8ad0f21a19e0@googlegroups.com> <mailman.3525.1363708963.2939.python-list@python.org> <dd31732d-a26f-4a8e-b9d5-0e76bd4c3b55@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.3529.1363713205.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 03/19/2013 12:36 PM, Bodhi wrote:
> 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.
>

As I said, python calls the C free() function, whether it's when an 
object's ref-count goes to zero, or whether it's during a gc call, where 
circular refs are freed.

But free() does not necessarily release the memory to the OS.  And the 
times it does depends on which C library is being used, and what OS it's 
running on.

If the freed memory affects top in some situations, it's a C library 
detail.  I've written a replacement C allocator in the past for Windows 
that used a different scheme for blocks over a certain threshold, and 
when those blocks were freed, it gave them back to the OS.  But such 
blocks were multiples of 64k, which was the increment for VirtualAlloc.




-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Wierd behavior of gc.collect Bodhi <amitdev@gmail.com> - 2013-03-19 08:47 -0700
  Re: Wierd behavior of gc.collect Dave Angel <davea@davea.name> - 2013-03-19 12:02 -0400
    Re: Wierd behavior of gc.collect Bodhi <amitdev@gmail.com> - 2013-03-19 09:36 -0700
      Re: Wierd behavior of gc.collect Dave Angel <davea@davea.name> - 2013-03-19 13:13 -0400
        Re: Wierd behavior of gc.collect Bodhi <amitdev@gmail.com> - 2013-03-19 21:51 -0700
        Re: Wierd behavior of gc.collect Bodhi <amitdev@gmail.com> - 2013-03-19 21:51 -0700
    Re: Wierd behavior of gc.collect Bodhi <amitdev@gmail.com> - 2013-03-19 09:36 -0700

csiph-web