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


Groups > comp.lang.python > #197810

Re: get_used_memory

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.lang.python
Subject Re: get_used_memory
Date Sun, 14 Jun 2026 01:09:00 -0000 (UTC)
Organization A noiseless patient Spider
Lines 25
Message-ID <110kuvc$3a32m$7@dont-email.me> (permalink)
References <110fvf3$1tqe3$1@dont-email.me> <slrn112nclh.5fs.jon+usenet@raven.unequivocal.eu> <8733yq9qov.fsf@nightsong.com>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Sun, 14 Jun 2026 01:09:01 +0000 (UTC)
Injection-Info dont-email.me; logging-data="3476566"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CJFz370HFVhiiJfMJmW1s"; posting-host="b1bf6620f1a4372394d122a643211c62"
User-Agent Pan/0.165 (Kostiantynivka)
Cancel-Lock sha1:bVrveOlNjYV5BOWBScO6cHH1Fjg= sha256:ggGVNV1k7ZJP365fOCQkthN6EGQEG0PE0i/7TSB5xFI= sha1:Ao8AoWbS4ogIda8tqnfne8RP8Fc=
Xref csiph.com comp.lang.python:197810

Show key headers only | View raw


On Sat, 13 Jun 2026 12:38:08 -0700, Paul Rubin wrote:

> with open('/proc/meminfo') as meminfo:
>     info = dict(line.split()[:2] for line in meminfo)

Output on my machine of

    print("Used memory: %d Kb" % (info["MemTotal"] - info["MemFree"] - info["Buffers"] - info["Cached"] + info["SwapTotal"] - info["SwapFree"] - info["SwapCached"]))

from my version:

    Used memory: 13646656 Kb

From your version:

    ---------------------------------------------------------------------------
    KeyError                                  Traceback (most recent call last)
    Cell In[3], line 3
          1 with open('/proc/meminfo') as meminfo:
          2     info = dict(line.split()[:2] for line in meminfo)
    ----> 3 print("Used memory: %d Kb" % (info["MemTotal"] - info["MemFree"] - info["Buffers"] - info["Cached"] + info["SwapTotal"] - info["SwapFree"] - info["SwapCached"]))

    KeyError: 'MemTotal'

Tisk-tisk ...

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


Thread

get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-12 03:46 +0000
  Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-12 07:18 +0000
    Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 12:38 -0700
      Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 19:58 +0000
        Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 20:02 +0000
          Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 14:13 -0700
            Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 21:35 +0000
              Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 15:20 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 22:53 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 17:23 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-15 00:40 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 18:18 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-15 07:20 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-15 12:02 -0700
                Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 01:10 +0000
      Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 01:09 +0000
        Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 01:28 -0700
          Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 23:56 +0000

csiph-web