Skip to content

Commit

Permalink
Curate the garbage collector
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jul 21, 2019
1 parent fc2cef1 commit a591a03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -63,6 +63,7 @@ Development
- Improve tooling and inline documentation
- Add option ``main.fastboot`` for skipping LTE modem teardown
for faster development iterations
- Curate the garbage collector


2019-06-22 0.5.1
Expand Down
3 changes: 3 additions & 0 deletions terkin/datalogger.py
Expand Up @@ -174,6 +174,9 @@ def loop(self):
# Read sensors.
readings = self.read_sensors()

# Run the garbage collector.
self.device.run_gc()

# Transmit data.
self.transmit_readings(readings)

Expand Down
8 changes: 7 additions & 1 deletion terkin/device.py
Expand Up @@ -99,11 +99,17 @@ def start_rtc(self):

def run_gc(self):
"""
Run a garbage collection.
Curate the garbage collector.
https://docs.pycom.io/firmwareapi/micropython/gc.html
For a "quick fix", issue the following periodically.
https://community.hiveeyes.org/t/timing-things-on-micropython-for-esp32/2329/9
"""
import gc
log.info('Start curating the garbage collector')
gc.collect()
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
log.info('Curating the garbage collector finished')

def configure_rgb_led(self):
"""
Expand Down

0 comments on commit a591a03

Please sign in to comment.