Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'case.': 0.05; 'debug': 0.05; 'python': 0.09; 'malloc': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.11; 'library': 0.15; 'expected,': 0.16; 'gc.collect()': 0.16; 'wrote:': 0.17; 'memory': 0.18; 'supposed': 0.21; 'libraries': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'setting': 0.26; 'am,': 0.27; 'question': 0.27; '(as': 0.27; "doesn't": 0.28; 'objects': 0.29; 'this.': 0.29; 'maybe': 0.29; 'usually': 0.30; 'returned': 0.30; 'figure': 0.30; 'problem': 0.33; 'operations': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'doing': 0.35; "won't": 0.35; 'there': 0.35; 'but': 0.36; 'operating': 0.36; 'does': 0.37; 'option': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'system.': 0.39; 'release': 0.39; 'skip:u 10': 0.60; 'free': 0.61; 'show': 0.63; 'here': 0.65; 'results': 0.65; '2013': 0.84; 'drops': 0.91; 'angel': 0.93 X-Received: by 10.50.53.232 with SMTP id e8mr541839igp.14.1363711013666; Tue, 19 Mar 2013 09:36:53 -0700 (PDT) Newsgroups: comp.lang.python Date: Tue, 19 Mar 2013 09:36:53 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=72.163.216.217; posting-account=tKULhwoAAADGQa_90ngAqNBJ-1rg4uyR References: <76cc4613-8086-4b36-a8bd-8ad0f21a19e0@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 72.163.216.217 MIME-Version: 1.0 Subject: Re: Wierd behavior of gc.collect From: Bodhi To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363713588 news.xs4all.nl 6955 [2001:888:2000:d::a6]:59309 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41537 I know this, but my question is what does gc.collect do which results in th= e c library to free memory? Usually it is because of unreferenced objects i= n 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: >=20 > > I have a python process that does some operations and is supposed to re= lease 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. Imm= ediately after doing the collect memory usage drops as expected, but strang= ely gc.collect() returns 0. >=20 > > This means I cannot find out what the problem is by setting the debug o= ption on gc which is what I usually do to figure out issues like this. >=20 > > >=20 > > Maybe its that my understanding about it is incorrect, but if gc.collec= t returned 0, how come some memory was freed? >=20 > > >=20 >=20 >=20 > To put it simply, top won't in general show you that things are freed.=20 >=20 > The C libraries for malloc and free will reuse the memory, but not=20 >=20 > usually release it to the operating system. So it's not usually going=20 >=20 > to show up in 'top.' >=20 >=20 >=20 > There was a long thread on this quite recently, but I can't seem to find= =20 >=20 > it right now. >=20 >=20 >=20 >=20 >=20 > --=20 >=20 > DaveA