Skip to main content
Help us improve Python packaging – donate today!

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/.

Release history Release notifications

This version
History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
memon-0.1-py2.py3-none-any.whl (5.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Mar 29, 2017
memon-0.1.tar.gz (12.6 kB) Copy SHA256 hash SHA256 Source None Mar 29, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page