Memory consumption with array('B'... #12440
Replies: 2 comments 3 replies
-
I did not experience the problem you mentioned. Here are the results of my test:
The only explanation I can think of for your case is that the memory used for |
Beta Was this translation helpful? Give feedback.
-
so, I restarted micropython and did this:
It appears that gc.mem_free is returning entirely bogus numbers, even after gc.collect. With only 9k free after one allocation, I succeeded in allocating two more 65536 byte arrays. Trying to allocate a fourth failed, as expected. I have elevated this to a bug report. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
in MicroPython '3.4.0; MicroPython v1.20.0 on 2023-04-26', on an RPi Pico,
I would assume that an object such as array('B', range(x)) would take up 'x' bytes plus the header. It seems to take massively more, as seen below. My 65536 element array makes about 98k bytes disappear from the heap. It all reappears properly when I delete the object and re-collect, so it isn't a leak.
I note that bytearray() does consume the correct amount, while array.array('B'...) does not. For practical purposes, I probable would use bytearray anyways, but what is happening with array.array?
Does anyone know why this is so, or why it must be (if it isn't a bug)?
Thanks much.
Beta Was this translation helpful? Give feedback.
All reactions