Skip to main content

Remember Me

Build Status

RememberMe is a handy tool for memory problems in Python. It computes the total memory usage of Python objects.

RememberMe is a replacement for sys.getsizeof

sys.getsizeof is almost confusing in Python:

import sys
a = [1, 2, 3]
b = [a, a, a]
print(sys.getsizeof(a) == sys.getsizeof(b))  # Can you believe the result is `True`?

While rememberme gives you a clear idea how large an object is.

from rememberme import memory
a = [1, 2, 3]
b = [a, a, a]
print(memory(a))  # 172 bytes!
print(memory(b))  # 260 bytes!

Installation

pip install rememberme

More features

Check out memory usage in the current frame:

from rememberme import memory
def foo():
    a = [1, 2, 3]
    b = [a, a, a]
    print memory()
foo()  # 260 bytes. Note `a` is included in `b`.

Check out top memory consumers:

from rememberme import top
def foo():
    a = [1, 2, 3]
    b = [a, a, a]
    mem_top = top()  # with no args, check current frame
    print(mem_top[0])  # `b` and its memory usage
    print(mem_top[1])  # `a` and its memory usage

Even pretty print the result!

from rememberme import mem_print
def foo():
    a = [1, 2, 3]
    b = [a, a, a]
    mem_print(b)
foo()

Output:

                           ┌int (28.0B)
             ┌list (172.0B)┼int (28.0B)
             │             └int (28.0B)
             │             ┌int (28.0B)
list (260.0B)┼list (172.0B)┼int (28.0B)
             │             └int (28.0B)
             │             ┌int (28.0B)
             └list (172.0B)┼int (28.0B)
                           └int (28.0B)

Known issues and limitations

  • For better performance (and making better sense), the global dict, as well as modules, are not included in the memory usage of any objects.
  • We essentially relies on tp_traverse to traverse the object graph. For C extensions, memory usage might be underestimated under various circumstances. For the most common numpy.ndarray, a specific procedure is defined to probe the memory usage correctly, but no correctness is guaranteed for other C extensions, which may have undetectable momery leaks within themselves.

Metadata

Release files for rememberme 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rememberme 0.1.1
File Size Uploaded Provenance
rememberme-0.1.1.tar.gz 66.9 kB Without provenance Details

Release files / rememberme-0.1.1.tar.gz

Download URL rememberme-0.1.1.tar.gz
Size 66.9 kB
Tags Source
SHA-256 checksum
How to use checksums
834538f848351e1d2d4ef8fe413c03a6222f8afbbdbaa1602a7c5b1f5de0b924
BLAKE2b-256 checksum
How to use checksums
9b09fd6c9869a81a4285b92d0d441d6f1acb56bd10f93165e9e9fb370a4053d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Security for rememberme 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page