Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.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; 'interpreter': 0.05; 'restarting': 0.07; 'socket': 0.07; 'cleanup': 0.09; 'compact': 0.09; 'integers': 0.09; 'subject:skip:f 10': 0.09; 'subject:still': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'blocks': 0.16; 'down...': 0.16; 'expensive,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ironpython': 0.16; 'personally,': 0.16; 'rebuild': 0.16; 'right;': 0.16; 'sequential': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'fixed.': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'locations': 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; '(including': 0.33; 'linux': 0.33; 'running': 0.33; 'etc': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'should': 0.36; 'application': 0.37; 'so,': 0.37; 'level': 0.37; 'starting': 0.37; 'sometimes': 0.38; 'manager': 0.38; 'connections': 0.38; 'anything': 0.39; 'expensive': 0.39; 'moving': 0.39; 'subject:" ': 0.39; 'even': 0.60; 'around.': 0.60; 'removing': 0.60; 'managers': 0.61; 'high': 0.63; 'more': 0.64; 'benefit': 0.68; 'periodically': 0.68; 'caused': 0.69; 'gotten': 0.74; 'removal': 0.74; 'clearer': 0.84; 'correction,': 0.84; "it'd": 0.84; 'subject:High': 0.84; 'disposal': 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=TNqNQJwAu1LYBfe6QQUSHHj7h2TMjz2ypUy9mr+1DSA=; b=UDACiWziVkR9NCJszAvtuHlJRwfLqDz4nStv0LiBIUxaVgtZQkQlfMipNnPkg8ItwX qRbfRaGCXSgcbPjT4QttYTjlQXvEafXSNIEC/dmDY8ckSGvzM88dUZKDXnwF4IpnAA+O BwS5zi2/zxPqFUYBrflgZ7wXur11UPF4/7K4u3EpEs8kaB+rPcf07xpdlBzl8c1SyIPb 7cH3MoMi6k8xEwgSfYxzG7CVQW4oUg7HKSxLDF1VnInWItwFm5lcw4mB0r5CXnM7MSgZ lgRbD1j0GVtinPv+3W5wxjRGLH5PKmO3pUQIMUWAafc8RoN/WJhJUTnbtL6pt0aasJhD pm5Q== MIME-Version: 1.0 X-Received: by 10.50.66.234 with SMTP id i10mr2957405igt.34.1412389358792; Fri, 03 Oct 2014 19:22:38 -0700 (PDT) In-Reply-To: <542f470b$0$13003$c3e8da3$5496439d@news.astraweb.com> References: <542f470b$0$13003$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 4 Oct 2014 12:22:38 +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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412389367 news.xs4all.nl 2872 [2001:888:2000:d::a6]:52310 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 5907 X-Received-Body-CRC: 688367807 Xref: csiph.com comp.lang.python:78677 On Sat, Oct 4, 2014 at 11:02 AM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> 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. > > I welcome correction, but I understand that both the JVM and the CLR memory > managers move memory around. That's why Jython and IronPython use > sequential integers as object IDs, since memory locations are not fixed. Right; I should have made it clearer that there's no proof that it'd help anything *in CPython*. Removing the GIL is periodically proposed, too, but there's no proof that its removal would benefit CPython; it's not just that nobody's gotten around to writing a memory compactor for CPython. > Ironically, the cost of restarting the process periodically is likely to be > orders of magnitude more expensive than that of moving a few blocks of > memory around from time to time. Especially on Windows, where starting > processes is expensive, but even on Linux you have to shut the running > application down, then start it up again and rebuild all the internal data > structures that you just tore down... Maybe. But you deal with a number of things all at once: 1) Code updates (including interpreter updates) 2) Compaction of Python objects 3) Disposal of anything that got "high level leaked" - unintended longevity caused by a global reference of some sort 4) Cleanup of low-level allocations that don't go through the Python memory manager etc etc etc. So, yes, it's expensive. And sometimes it's not even possible (there's no way to retain socket connections across a restart, AFAIK). But it's there if you want it. Personally, I like to keep processes running, but that's me. :) ChrisA