Perhaps to help demystify the GC (garbage collector) a bit.
When python needs to allocate memory, it goes to the heap, and tries to allocate it. If the allocation succeeds, then life is good and your program continues.
If, however, the allocation fails, then the GC is run.
The GC figures out which chunks of previously allocated memory are no longer being used and frees them.
Then the allocation will be attempted again. If it fails after the GC, then a MemoryError is raised.
So whether the GC runs or not depends on whether a given bit of code allocates memory, and whether that allocation fails due to a full heap.
Which firmware version do I have installed?
-
- Posts: 144
- Joined: Mon Jul 25, 2022 9:45 pm
Re: Which firmware version do I have installed?
Speaking of using sys.implementation, what is the _mpy property? It is an integer value, i.e. 4102. Is that a build number of micropython firmware image? Or?