forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Milestone
Description
Currently most native objects don't use m_new_obj_with_finaliser(), which marks the object as having __del__() to call when the object is gc'd. Only network.socket and audiobusio.I2SOut currently do this, and I'm adding another use in _bleio.
audiobusio.I2SOut.__del__() just called its deinit(), which seems like a good idea. We could do the same for other objects with deinit(), like busio.*, etc. This would free up pins when their holding objects were gc'd.
I'm not sure this has a lot of practical value, because if you want reuse a pin, you should call deinit() on its holding object immediately, but it would make a gc.collect() free up pins if the holding objects were gc'd. Otherwise the pins would just stay allocated.