I'm really enjoying this great little board with an ssd1306 I2C graphic display and noticed in the demo script supplied the use of a library called 'gc' to collect up space. While adding this command to a script of my own I noticed a few other keywords flash up, such as cos.
Is there any documentation for this library? If so where? Does anyone know what else gc does?
ItsyBitsy M0 Express - gc library
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Tonygo
- Posts: 108
- Joined: Fri Apr 13, 2018 11:09 am
Re: ItsyBitsy M0 Express - gc library
Since posting I had a thought and typed a few commands into Mu's REPL:
>>> import gc
>>> dir(gc)
['__name__', 'collect', 'disable', 'enable', 'isenabled', 'mem_free', 'mem_alloc']
>>> gc.mem_free()
18496
>>> gc.mem_alloc()
1552
>>> gc.collect()
>>> gc.mem_free()
19168
So:
gc.mem_free() provides the space you have left
gc.mem_alloc() how much space used
gc.collect() does a garbage collection? and gets more room
I suppose the others allow you to do this within a script and turn gc ON/OFF and see if it is ON.
Am I right?
>>> import gc
>>> dir(gc)
['__name__', 'collect', 'disable', 'enable', 'isenabled', 'mem_free', 'mem_alloc']
>>> gc.mem_free()
18496
>>> gc.mem_alloc()
1552
>>> gc.collect()
>>> gc.mem_free()
19168
So:
gc.mem_free() provides the space you have left
gc.mem_alloc() how much space used
gc.collect() does a garbage collection? and gets more room
I suppose the others allow you to do this within a script and turn gc ON/OFF and see if it is ON.
Am I right?
- adafruit_support_carter
- Posts: 29153
- Joined: Tue Nov 29, 2016 2:45 pm
- Tonygo
- Posts: 108
- Joined: Fri Apr 13, 2018 11:09 am
Re: ItsyBitsy M0 Express - gc library
Thank you for a very quick and useful reply.
Please be positive and constructive with your questions and comments.