Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'cpython': 0.05; 'back.': 0.09; 'compact': 0.09; 'deploy': 0.09; 'quarter': 0.09; 'restart': 0.09; 'restarted': 0.09; 'subject:skip:f 10': 0.09; 'subject:still': 0.09; 'worse': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(it': 0.16; 'behavior,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'policy:': 0.16; 'processes.': 0.16; 'sorts': 0.16; 'sat,': 0.16; 'ignore': 0.16; 'language': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; '(the': 0.22; 'memory': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; 'exhibit': 0.24; 'tend': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'see,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'comments': 0.31; 'limitation': 0.33; 'used,': 0.33; "i'd": 0.34; 'problem.': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'half': 0.37; 'virtual': 0.37; 'too': 0.37; 'level': 0.37; 'christian': 0.38; 'process,': 0.38; 'solving': 0.38; 'that,': 0.38; 'anything': 0.39; 'moving': 0.39; 'subject:" ': 0.39; 'though,': 0.39; 'problems.': 0.60; 'worry': 0.60; 'most': 0.60; 'new': 0.61; 'effective': 0.61; 'strictly': 0.61; "you'll": 0.62; "you've": 0.63; 'high': 0.63; 'happen': 0.63; 'fact,': 0.69; "it'd": 0.84; 'partially': 0.84; 'subject:High': 0.84; 'processes,': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=aa+UBN+9YmQN17zGHV5VBg/b48IyWBeNUz5Gzyj/vMQ=; b=raEPIdiDorJ0tH5A6ihO20e22foPGw2vCxeT5s4sPTSDpGFuGG/8ZCi7/3Tl6ayFXH jiyPH6FL6MYmgPPQaRfZAq22QnIJt7n+Bee3I9sW8Eo3k7JxnfKmpvwo1CmGzoBlmp0W /s0TxvRoVIvgg3RKys3BUQhj/ev3wOQxm8uEKt8qIwk8Js+5mSb0L4qxlmQ0g+p8EknU iiHNqXou0YsHuM4jNg5/K35MJ/rgCT5o47Wct03662sffU1iWqWAuvYamP3SgvWB/p8e nI3O6YceOsdptkUImSIO5P1e7/uV4IDCqN+CBtyFKZ5gOwHdRe6qT10HYlciBxLa75GX TmzQ== MIME-Version: 1.0 X-Received: by 10.42.90.80 with SMTP id j16mr16226126icm.27.1412378800366; Fri, 03 Oct 2014 16:26:40 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Oct 2014 09:26:40 +1000 Subject: Re: "High water" Memory fragmentation still a thing? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412378803 news.xs4all.nl 2840 [2001:888:2000:d::a6]:50997 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78673 On Sat, Oct 4, 2014 at 4:36 AM, Croepha wrote: > What this means is that processes that do need to use a lot of memory will > exhibit a "high water" behavior, where they remain forever at the level of > memory usage that they required at their peak. This is almost never true. What you will see, though, is something like Christian described; pages get allocated, and then partially used, and you don't always get all that memory back. In theory, a high level language like Python would be allowed to move objects around to compact memory, but CPython doesn't do this, and there's no proof that it'd really help anything anyway. (Look at Christian's comments about "Should you return it or not?" and the cost of system calls... now consider the orders-of-magnitude worse cost of actually moving memory around.) This is why a lot of long-duration processes are built to be restarted periodically. It's not strictly necessary, but it can be the most effective way of solving a problem. I tend to ignore that, though, and let my processes just keep on running... for 88 wk 4d 23:56:27 so far, on one of those processes. It's consuming less than half a gig of virtual memory, quarter gig resident, and it's been doing a fair bit (it keeps all sorts of things in memory to avoid re-decoding from disk). So don't worry too much about memory usage until you see that there's actually a problem; with most Python processes, you'll restart them to deploy new code sooner than you'll restart them to fix memory problems. (The above example isn't a Python process, and code updates happen live.) In fact, I'd advise that as a general policy: Don't panic about any Python limitation until you've proven that it's actually a problem. :) ChrisA