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


Groups > comp.lang.python > #41536

Re: Wierd behavior of gc.collect

Path csiph.com!usenet.pasdenom.info!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.035
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'case.': 0.05; 'function,': 0.07; 'python': 0.09; "object's": 0.09; 'library': 0.15; 'blocks': 0.16; 'increment': 0.16; 'multiples': 0.16; 'zero,': 0.16; 'wrote:': 0.17; 'circular': 0.17; 'memory': 0.18; 'windows': 0.19; 'written': 0.20; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'used,': 0.27; 'question': 0.27; "doesn't": 0.28; 'objects': 0.29; 'usually': 0.30; 'running': 0.32; 'certain': 0.33; 'goes': 0.33; 'affects': 0.33; 'to:addr :python-list': 0.33; 'said,': 0.35; 'pm,': 0.35; 'but': 0.36; 'depends': 0.36; 'does': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'free': 0.61; 'back': 0.62; 'necessarily': 0.63; 'different': 0.63; 'times': 0.63; 'here': 0.65; 'gave': 0.65; 'results': 0.65; 'detail.': 0.65; 'received:74.208': 0.71; 'situations,': 0.84
Date Tue, 19 Mar 2013 13:13:11 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <dd31732d-a26f-4a8e-b9d5-0e76bd4c3b55@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:c0P4X5+S+qQOj0JY1ul2E/3fuJMmsB4TstdeSfUgLz3 HlXyv1W7AATOcumzc6obfY7AoYCnJK+/pr05SGnSHULQYWxKmB fC3BOoKB6pmFgxKi7Rzb+GNdLMZXzXTt9781ugCXLXfZFPqU8H xrbOptxFY1HDPoNOPAKcX8ZkFjHjz4K4Guh7AsjocqWnqusBkw VmQy8CDnbfFgX71kSWMJ0fwZw+3bNlqMAZJEcEZkabA10iVqbG 3Oa/zmRvkOwyb2hzIVDXYx7C+6ep/kMaAH4jFEkOHqVhH1GtNH mWsgl0RWVUp9hiA26JOeG46kBRkSCGzf9xR8vgbfLBZ5SkE6g= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3529.1363713205.2939.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363713205 news.xs4all.nl 6978 [2001:888:2000:d::a6]:55482
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41536

Show key headers only | 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