Skip to main content

Memory Profiler

This is a python module for monitoring memory consumption of a process as well as line-by-line analysis of memory consumption for python programs.

Installation

To install through easy_install or pip:

$ easy_install -U line_profiler # pip install -U line_profiler

To install from source, download the package, extract and type:

$ python setup.py install

Usage

The line-by-line profiler is used much in the same way of the line_profiler: you must first decorate the function you would like to profile with @profile:

@profile
def my_func():
    a = np.zeros((100, 100))
    b = np.zeros((1000, 1000))
    c = np.zeros((10000, 1000))
    return a, b, c

then execute the code passing the option “-m memory_profiler” to the python interpreter. If the file name was example.py, this would result in:

$ python -m line_profiler example.py

Output will follow:

Line #    Mem usage   Line Contents
===================================
     3                @profile
     4                def my_func():
     5     13.68 MB       a = np.zeros((100, 100))
     6     13.77 MB       b = np.zeros((1000, 1000))
     7     21.40 MB       c = np.zeros((10000, 1000))
     8     97.70 MB       return a, b, c

Bugs & wishlist

It currently prints the memory at line before the line has been executed. It would be nice to print consumption after the line has been executed. Maybe also print the increment in memory consumption.

Development

Latest sources are available from github:

https://github.com/fabianp/memory_profiler

Author: Fabian Pedregosa <fabian@fseoane.net> License: Simplified BSD

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memory_profiler-0.2.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file memory_profiler-0.2.tar.gz.

File metadata

  • Download URL: memory_profiler-0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for memory_profiler-0.2.tar.gz
Algorithm Hash digest
SHA256 bef4419cc18d278fca8aabb7714463def9963390de89ba215cacab429c582fd0
MD5 57701c8a4203d55ab0ea4b823800f7f8
BLAKE2b-256 b24bf783b2ed16c5574976a6cd7f07738a58d4fb45f77ff2dbb11ffc17fdb7bb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.61.0

2 files

0.60.0

1 file

0.59.0

1 file

0.58.0

1 file

0.57.0

1 file

0.55.0

1 file

0.54.0

1 file

0.52.0

1 file

0.51.0

1 file

0.50.0

1 file

0.49.0

1 file

0.48.0

1 file

0.47

1 file

0.46

1 file

0.45

1 file

0.44

1 file

0.43

1 file

0.42

1 file

0.41

1 file

0.40

1 file

0.39

1 file

0.38

1 file

0.37

1 file

0.36

1 file

0.35

1 file

0.34

1 file

0.33

1 file

0.32

1 file

0.31

1 file

0.30

1 file

0.29

1 file

0.28

1 file

0.27

1 file

0.26

1 file

0.25

1 file

0.24

1 file

0.23

1 file

0.22

1 file

0.21

1 file

0.20

1 file

0.19

1 file

0.18

1 file

0.17

1 file

0.16

1 file

0.15

1 file

0.14

1 file

0.13

1 file

0.12

1 file

0.11

1 file

0.10

1 file

0.9

1 file

0.8

1 file

0.7

1 file

0.5

1 file

0.4

1 file

0.3

1 file

This release

0.2 This release

1 file

0.1

1 file

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