Skip to main content

Simple Memory Monitor that helps to decide if it is time to dump data to disk.

Project description

Very simple memory monitor that records the percent of memory used. This can be useful if you want to dump data to disk if memory consumptions becomes too high.

Description and Usage

The MemoryMonitor class takes an interval and a memory_limit in percent.

To start recording memory usage:

from memon import MemoryMonitor
import time
memmon = MemoryMonitor(interval=0.1)
memmon.start()
memmon.start_recording()
time.sleep(1)
memmon.stop_recording()
assert len(memmon.history) == 10

If historical data is recorded this can be used to query if memory usage will keep under the memory limit. This is done by calling:

memmon.memory_available()

This function makes some assumptions:

  • The Python process is the main memory user on the system.

  • Any big fluctuations in memory usage are because of memory allocation/deallocation of the process running the memon.

  • We want to fit the average fluctuation that occurs during processing under the memory limit.

Because of these assumptions the memory_available() function calculates:

delta = max(history) - min(history)
level = mean(history) + delta
level < memory_limit

Note

This project has been set up using PyScaffold 2.5.7. For details and usage information on PyScaffold see http://pyscaffold.readthedocs.org/.

Project details


Download files

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

Source Distribution

memon-0.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

memon-0.1-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file memon-0.1.tar.gz.

File metadata

  • Download URL: memon-0.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for memon-0.1.tar.gz
Algorithm Hash digest
SHA256 6b5201f0a4655448e7d1ae42a4c1d3b640d1c9d60178482524edbebf915757fb
MD5 f5135a16a7a3d916e78d187803cd1e93
BLAKE2b-256 736a2b36bae40a3fd55ecfb78d7b7f66bbd5d51c8755fde044645791bded703b

See more details on using hashes here.

File details

Details for the file memon-0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for memon-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dd40cc1c922d39953efbc71dbd95b9282dbc89ea308ed1dd715da2cfbdaa3e56
MD5 6da8d6b6b2089ab31fcaa6900fb7d7d1
BLAKE2b-256 3fba584cb98878479d39a08d1ef042f6838fb90703ee2f53e7b2b2b407d82bbd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page