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 4.6. For details and usage information on PyScaffold see https://pyscaffold.org/.
Metadata
Release files for memon 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| memon-0.3.0.tar.gz | 16.5 kB | Details |
Release files / memon-0.3.0.tar.gz
| Download URL | memon-0.3.0.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bd6a7debb0441a03932cc393943dd6a6b981068be231b3370f492c3546bed93
|
|
BLAKE2b-256 checksum How to use checksums |
dbd2e6b1ddfe231c42f5706455ddefa16cf2c306dd35b829086920f5ac80ad57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|