当前位置: 首页>>代码示例>>Python>>正文


Python gc.mem_alloc方法代码示例

本文整理汇总了Python中gc.mem_alloc方法的典型用法代码示例。如果您正苦于以下问题:Python gc.mem_alloc方法的具体用法?Python gc.mem_alloc怎么用?Python gc.mem_alloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gc的用法示例。


在下文中一共展示了gc.mem_alloc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_gc

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def run_gc(self):
        """
        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.threshold(gc.mem_free() // 4 + gc.mem_alloc())
        log.info('Collecting garbage')
        gc.collect()
        #log.info('Curating the garbage collector finished')
        log.info('Curating the garbage collector finished. Free memory: %s', gc.mem_free()) 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:18,代码来源:device.py

示例2: collect_garbage

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def collect_garbage(self):
        gc.collect()
        if config_lora.IS_MICROPYTHON:
            print('[Memory - free: {}   allocated: {}]'.format(gc.mem_free(), gc.mem_alloc())) 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:6,代码来源:sx127x.py

示例3: _memory

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def _memory(self):
        count = 0
        while self.isconnected():  # Ensure just one instance.
            await asyncio.sleep(1)  # Quick response to outage.
            count += 1
            count %= 20
            if not count:
                gc.collect()
                print('RAM free {} alloc {}'.format(gc.mem_free(), gc.mem_alloc())) 
开发者ID:peterhinch,项目名称:micropython-mqtt,代码行数:11,代码来源:mqtt_as.py

示例4: from_pyboard

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def from_pyboard(self):
        client = self.client
        while True:
            istr = await self.await_obj(20)  # wait for string (poll interval 20ms)
            s = istr.split(SEP)
            command = s[0]
            if command == PUBLISH:
                await client.publish(s[1], s[2], bool(s[3]), int(s[4]))
                # If qos == 1 only returns once PUBACK received.
                self.send(argformat(STATUS, PUBOK))
            elif command == SUBSCRIBE:
                await client.subscribe(s[1], int(s[2]))
                client.subscriptions[s[1]] = int(s[2])  # re-subscribe after outage
            elif command == MEM:
                gc.collect()
                gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
                self.send(argformat(MEM, gc.mem_free(), gc.mem_alloc()))
            elif command == TIME:
                t = await client.get_time()
                self.send(argformat(TIME, t))
            else:
                self.send(argformat(STATUS, UNKNOWN, 'Unknown command:', istr))

# Runs when channel has synchronised. No return: Pyboard resets ESP on fail.
# Get parameters from Pyboard. Process them. Connect. Instantiate client. Start
# from_pyboard() task. Wait forever, updating connected status. 
开发者ID:peterhinch,项目名称:micropython-mqtt,代码行数:28,代码来源:mqtt.py

示例5: get

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def get(self, data):
        mem = {'mem_alloc': gc.mem_alloc(),
               'mem_free': gc.mem_free(),
               'mem_total': gc.mem_alloc() + gc.mem_free()}
        sta_if = network.WLAN(network.STA_IF)
        ifconfig = sta_if.ifconfig()
        net = {'ip': ifconfig[0],
               'netmask': ifconfig[1],
               'gateway': ifconfig[2],
               'dns': ifconfig[3]
               }
        return {'memory': mem, 'network': net}


# RESTAPI: GPIO status 
开发者ID:belyalov,项目名称:tinyweb,代码行数:17,代码来源:esp8266.py

示例6: _print_debug_cycle

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def _print_debug_cycle(self, init=False):
        pre_alloc = gc.mem_alloc()
        pre_free = gc.mem_free()

        if self.debug_enabled:
            if init:
                print('KMKInit(release={})'.format(KMK_RELEASE))

            print(self)
            print(self._state)
            print(
                'GCStats(pre_alloc={} pre_free={} alloc={} free={})'.format(
                    pre_alloc, pre_free, gc.mem_alloc(), gc.mem_free()
                )
            ) 
开发者ID:KMKfw,项目名称:kmk_firmware,代码行数:17,代码来源:kmk_keyboard.py

示例7: mem_manage

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def mem_manage():         # Necessary for long term stability
    while True:
        await asyncio.sleep_ms(100)
        gc.collect()
        gc.threshold(gc.mem_free() // 4 + gc.mem_alloc()) 
开发者ID:micropython-IMU,项目名称:micropython-fusion,代码行数:7,代码来源:fusionlcd.py

示例8: get_gc_stats

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def get_gc_stats(self):
        import gc
        return {
            'mem_alloc': gc.mem_alloc(),
            'mem_free': gc.mem_free()
        } 
开发者ID:fadushin,项目名称:esp8266,代码行数:8,代码来源:stats_api.py

示例9: handle_command

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def handle_command(self, args):
        import gc
        mem_alloc = gc.mem_alloc()
        mem_free = gc.mem_free()
        capacity = mem_alloc + mem_free
        print("    capacity\tfree\tusage")
        print("    {}\t{}\t{}%".format(capacity, mem_free, int(
            ((capacity - mem_free) / capacity) * 100.0)))
        if "-i" in args:
            import micropython
            micropython.mem_info(1) 
开发者ID:fadushin,项目名称:esp8266,代码行数:13,代码来源:ush.py

示例10: get_memory_stats

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def get_memory_stats(self):
        mem_alloc = gc.mem_alloc()
        mem_free = gc.mem_free()
        return {
            'mem_alloc': mem_alloc,
            'mem_free': mem_free
        } 
开发者ID:fadushin,项目名称:esp8266,代码行数:9,代码来源:api.py

示例11: mem

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def mem(level=None):
    import gc
    mem_alloc = gc.mem_alloc()
    mem_free = gc.mem_free()
    capacity = mem_alloc + mem_free
    print("    capacity\tfree\tusage")
    print("    {}\t{}\t{}%".format(capacity, mem_free, int(
        ((capacity - mem_free) / capacity) * 100.0)))
    if level:
        import micropython
        micropython.mem_info(level) 
开发者ID:fadushin,项目名称:esp8266,代码行数:13,代码来源:cmd.py

示例12: __init__

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def __init__(self, sleep_ms=5*1000, verbose=False) :
        TaskBase.__init__(self, sleep_ms)
        self.verbose = verbose
        self.mem_free = 0
        self.mem_alloc = 0
        self.min_collected = 2**32
        self.max_collected = 0
        self.sum_collected = 0
        self.num_collections = 0 
开发者ID:fadushin,项目名称:esp8266,代码行数:11,代码来源:task.py

示例13: perform

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def perform(self) :
        import gc
        mem_free_before = gc.mem_free()
        gc.collect()
        self.mem_free = gc.mem_free()
        self.mem_alloc = gc.mem_alloc()
        mem_collected = self.mem_free - mem_free_before
        if mem_collected < self.min_collected :
            self.min_collected = mem_collected
        if self.max_collected < mem_collected :
            self.max_collected = mem_collected
        self.sum_collected += mem_collected
        self.num_collections += 1
        return True 
开发者ID:fadushin,项目名称:esp8266,代码行数:16,代码来源:task.py

示例14: _garbage_collect

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def _garbage_collect(self):
        while True:
            await asyncio.sleep_ms(100)
            gc.collect()
            gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())

# Very basic window class. Cuts a rectangular hole in a screen on which content may be drawn 
开发者ID:peterhinch,项目名称:micropython-tft-gui,代码行数:9,代码来源:ugui.py

示例15: collect_garbage

# 需要导入模块: import gc [as 别名]
# 或者: from gc import mem_alloc [as 别名]
def collect_garbage(self):
        gc.collect()
        if __DEBUG__:
            print('[Memory - free: {}   allocated: {}]'.format(gc.mem_free(), gc.mem_alloc())) 
开发者ID:lemariva,项目名称:uPyLoRaWAN,代码行数:6,代码来源:sx127x.py


注:本文中的gc.mem_alloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。