memory usage: MicoPython vs. Python3

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
HermannSW
Posts: 197
Joined: Wed Nov 01, 2017 7:46 am
Contact:

memory usage: MicoPython vs. Python3

Post by HermannSW » Thu Oct 18, 2018 10:17 pm

I found only global memory information functions for MicroPython, and only object specific memory usage function in Python3:

https://docs.micropython.org/en/latest/ ... ained.html
micropython.mem_info() Print a summary of RAM utilisation.
gc.mem_free() Return the free heap size in bytes.

https://docs.python.org/3/library/sys.h ... module-sys
sys.getsizeof(object[, default]) Return the size of an object in bytes. ...

Is there an equivalent to sys.getsizeof(object) somewhere in MicroPython?
If not, can the object memory be determined otherwise in MicroPython?
Pico-W Access Point static file webserver:
https://github.com/Hermann-SW/pico-w

Tiny MicroPython robots (the PCB IS the robot platform)
viewtopic.php?f=5&t=11454

webrepl_client.py
https://github.com/Hermann-SW/webrepl#webrepl-shell

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: memory usage: MicoPython vs. Python3

Post by jickster » Mon Oct 22, 2018 2:43 pm

Yes there is

Code: Select all

// Whether to provide "sys.getsizeof" function
#define MICROPY_PY_SYS_GETSIZEOF (0)
But this unary operator has to be implemented by each type on which you wish to use it; this cannot be enforced at compile-time.

Post Reply