Salted Fish Micropy Standard Library-GC garbage collection

Salted Fish Micropy Standard Library-GC garbage collection


View micropython standard library

The gc module provides a garbage collection function that can recycle garbage generated during system operation. By default, automatic recycling is allowed.
garbage collector

Basic usage

import gc
gc.enable()
  • gc.enable()
    Allow automatic garbage collection

  • gc.disable()
    Prohibit automatic recycling, but you can manually recycle

  • gc.collect()
    recycle rubbish

  • gc.mem_alloc()
    Returns the amount of allocated memory

  • gc.mem_free()
    Returns the amount of remaining memory

! [Insert picture description here] (https://img-blog.csdnimg.cn/20191008162014265.png

Published 166 original articles · 22 praises · 10,000+ views

Guess you like

Origin blog.csdn.net/weixin_45020839/article/details/102393009