summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-24 23:12:25 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-24 23:12:25 +0100
commit0b13f3e026c842facf65743450246b15a8c2e064 (patch)
tree4793550a3701f766428d3f42e76086896e10100f /unix/main.c
parent564963a1700bfca8f053f864ad170d4a34a26270 (diff)
downloadmicropython-0b13f3e026c842facf65743450246b15a8c2e064.tar.gz
micropython-0b13f3e026c842facf65743450246b15a8c2e064.zip
py: Improve memory usage debugging; better GC AT dumping.
In unix port, mem_info(1) now prints pretty GC alloc table.
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/unix/main.c b/unix/main.c
index bb65e67c8d..3c0a877673 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -226,16 +226,20 @@ int usage(char **argv) {
}
#if MICROPY_MEM_STATS
-STATIC mp_obj_t mem_info(void) {
+STATIC mp_obj_t mem_info(mp_uint_t n_args, const mp_obj_t *args) {
printf("mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n",
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
printf("stack: " UINT_FMT "\n", mp_stack_usage());
#if MICROPY_ENABLE_GC
gc_dump_info();
+ if (n_args == 1) {
+ // arg given means dump gc allocation table
+ gc_dump_alloc_table();
+ }
#endif
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(mem_info_obj, mem_info);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mem_info_obj, 0, 1, mem_info);
#endif
STATIC mp_obj_t qstr_info(void) {