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


Groups > comp.lang.python > #48241

Re: Memory usage steadily going up while pickling objects

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'resulting': 0.04; 'cache': 0.07; 'none,': 0.07; 'objects,': 0.09; 'references,': 0.09; 'subject:while': 0.09; 'python': 0.11; 'stored': 0.12; '(about': 0.16; "(i'm": 0.16; 'any.': 0.16; 'debugged': 0.16; 'sqlite': 0.16; 'stuff,': 0.16; 'subject:usage': 0.16; 'unneeded': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'bit': 0.19; 'module': 0.19; 'not,': 0.20; 'memory': 0.22; 'minutes.': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; "haven't": 0.24; 'references': 0.26; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; "i'm": 0.30; 'code': 0.31; 'disable': 0.31; 'pickle': 0.31; 'produces': 0.31; 'another': 0.32; 'quite': 0.32; 'beginning': 0.33; 'could': 0.34; 'problem': 0.35; 'problem.': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'object,': 0.36; 'being': 0.38; 'sometimes': 0.38; 'saves': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'more': 0.64; 'chance': 0.65; 'effectively': 0.66; 'received:74.208': 0.68; 'default': 0.69; "it'd": 0.84; 'received:74.208.4.194': 0.84; 'thoroughly': 0.91
Date Fri, 14 Jun 2013 21:52:11 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6
MIME-Version 1.0
To python-list@python.org
Subject Re: Memory usage steadily going up while pickling objects
References <slrnkrn8ki.6mc.giorgos.tzampanakis@brilliance.eternal-september.org>
In-Reply-To <slrnkrn8ki.6mc.giorgos.tzampanakis@brilliance.eternal-september.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:g88capwVInQ56QRRP4sp4VFq2ZCw++ep4oMqn1kyv1p t8WmNtbfhCjgqdBDVPNYNDZxKboJCJJ/N0s4jLRBZmKwWbhZld xZxD6wLPPJzYptic5WBqO4+MZSoiX05+r54gdRA6C8NzQi+5N8 eCKR900S8bvMR/6zRtOza3Q4F6N39SS23m2kxv3E9I/XrGw8+6 7qAIDAm51biM5nWC+Bqm2JB30jblg80UqyCSdUfFLYObJU1BjS fCXBFjMh8jICtkHx3amCNek4Eb9/tn91DE7JQPjcLG+ic9VGy2 KRxj2gpy7OPdJpwlNBm8nedJ6ajYqR7QwYSqgqzLQgRFa5HnQ= =
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.3352.1371261146.3114.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371261146 news.xs4all.nl 15892 [2001:888:2000:d::a6]:42595
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48241

Show key headers only | View raw


On 06/14/2013 07:04 PM, Giorgos Tzampanakis wrote:
> I have a program that saves lots (about 800k) objects into a shelve
> database (I'm using sqlite3dbm for this since all the default python dbm
> packages seem to be unreliable and effectively unusable, but this is
> another discussion).
>
> The process takes about 10-15 minutes. During that time I see memory usage
> steadily rising, sometimes resulting in a MemoryError. Now, there is a
> chance that my code is keeping unneeded references to the stored objects,
> but I have debugged it thoroughly and haven't found any.
>
> So I'm beginning to suspect that the pickle module might be keeping an
> internal cache of objects being pickled. Is this true?
>

You can learn quite a bit by using the  sys.getrefcount() function.  If 
you think a variable has only one reference (if it had none, it'd be 
very hard to test), and you call sys.getrefcount(), you can check if 
your assumption is right.

Note that if the object is part of a complex object, there may be 
several mutual references, so the count may be more than you expect. 
But you can still check the count before and after calling the pickle 
stuff, and see if it has increased.

Note that even if it has not, that doesn't prove you don't have a problem.

Could the problem be the sqlite stuff?  Can you disable that part of the 
logic, and see whether just creating the data still produces the leak?


-- 
DaveA

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


Thread

Memory usage steadily going up while pickling objects Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-14 23:04 +0000
  Re: Memory usage steadily going up while pickling objects Dave Angel <davea@davea.name> - 2013-06-14 21:52 -0400
    Re: Memory usage steadily going up while pickling objects Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-15 09:41 +0000
      Re: Memory usage steadily going up while pickling objects Peter Otten <__peter__@web.de> - 2013-06-15 12:18 +0200
        Re: Memory usage steadily going up while pickling objects Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-15 11:06 +0000
      Re: Memory usage steadily going up while pickling objects dieter <dieter@handshake.de> - 2013-06-16 08:26 +0200
  Re: Memory usage steadily going up while pickling objects Peter Otten <__peter__@web.de> - 2013-06-15 08:37 +0200
    Re: Memory usage steadily going up while pickling objects Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-15 09:37 +0000

csiph-web