ItsyBitsy M0 Express - gc library

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Tonygo
 
Posts: 108
Joined: Fri Apr 13, 2018 11:09 am

ItsyBitsy M0 Express - gc library

Post by Tonygo »

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?

User avatar
Tonygo
 
Posts: 108
Joined: Fri Apr 13, 2018 11:09 am

Re: ItsyBitsy M0 Express - gc library

Post by Tonygo »

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?

User avatar
adafruit_support_carter
 
Posts: 29153
Joined: Tue Nov 29, 2016 2:45 pm

Re: ItsyBitsy M0 Express - gc library

Post by adafruit_support_carter »


User avatar
Tonygo
 
Posts: 108
Joined: Fri Apr 13, 2018 11:09 am

Re: ItsyBitsy M0 Express - gc library

Post by Tonygo »

Thank you for a very quick and useful reply.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”