Skip to main content

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

Project description

https://travis-ci.org/TUW-GEO/memon.svg?branch=master https://coveralls.io/repos/github/TUW-GEO/memon/badge.svg?branch=master https://badge.fury.io/py/memon.svg https://readthedocs.org/projects/memon/badge/?version=latest

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.

Installation

This package should be installable through pip:

pip install memon

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

Contribute

We are happy if you want to contribute. Please raise an issue explaining what is missing or if you find a bug. We will also gladly accept pull requests against our master branch for new features or bug fixes.

Development setup

For Development we recommend a conda environment

Guidelines

If you want to contribute please follow these steps:

  • Fork the memon repository to your account

  • make a new feature branch from the memon master branch

  • Add your feature

  • Please include tests for your contributions in one of the test directories. We use py.test so a simple function called test_my_feature is enough

  • submit a pull request to our master branch

Note

This project has been set up using PyScaffold 3.2.3. For details and usage information on PyScaffold see https://pyscaffold.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.2.0.tar.gz (14.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: memon-0.2.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for memon-0.2.0.tar.gz
Algorithm Hash digest
SHA256 913a3ba65e33703bdc950c53212d66c17f643a10e36bb8249797475c1bec0ef4
MD5 b2419bee3d0454b5cba824a650fe57cc
BLAKE2b-256 4d1d9e870f81ff3396093ba496054734a30e6621b4a359ea043df28854dbe86c

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