https://github.com/activestate/recipe-577504-compute-mem-footprint
Compute memory footprint of an object and its contents
https://github.com/activestate/recipe-577504-compute-mem-footprint
learning learning-by-doing learning-python recipes snippets
Last synced: 6 months ago
JSON representation
Compute memory footprint of an object and its contents
- Host: GitHub
- URL: https://github.com/activestate/recipe-577504-compute-mem-footprint
- Owner: ActiveState
- License: mit
- Created: 2019-10-09T20:50:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-19T21:19:18.000Z (over 5 years ago)
- Last Synced: 2025-04-05T04:51:15.076Z (7 months ago)
- Topics: learning, learning-by-doing, learning-python, recipes, snippets
- Language: Python
- Homepage: https://code.activestate.com/recipes/577504/
- Size: 8.79 KB
- Stars: 6
- Watchers: 25
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
This repository covers the following recipe from code.activestate.com:
[COMPUTE MEMORY FOOTPRINT OF AN OBJECT AND ITS CONTENTS](https://code.activestate.com/recipes/577504/)
*Created by Raymond Hettinger on Fri, 17 Dec 2010*
Recursive version sys.getsizeof(). Extendable with custom handlers.
By itself, the builtin function sys.getsizeof() is not helpful determining the size of a container and all of its contents.
This recipe makes it easy to find the memory footprint of a container and its context. Builtin containers and their subclasses are all fully supported. Extensions are provided for user-defined containers.
## Usage
If you already have the [State Tool] installed you can simply run
```
state activate ActiveState-Recipes/recipe-577504-compute-mem-footprint
```
If you do not have the [State Tool] installed you can use the following convenient one-liner.
Linux:
```
sh <(curl -q https://platform.activestate.com/dl/cli/install.sh) -n -f && state activate --path $HOME/ActiveState-Recipes/recipe-577504-compute-mem-footprint ActiveState-Recipes/recipe-577504-compute-mem-footprint
```
Windows:
```
powershell "Set-Item -Path Env:NOPROMPT_INSTALL -Value 'true'; IEX(New-Object Net.WebClient).downloadString('https://platform.activestate.com/dl/cli/install.ps1')" && state activate --path %APPDATA%/ActiveState-Recipes/recipe-577504-compute-mem-footprint ActiveState-Recipes/recipe-577504-compute-mem-footprint
```
macOS: not yet supported
[State Tool]: https://www.activestate.com/products/platform/state-tool/