aboutsummaryrefslogtreecommitdiff
path: root/py/qstr.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 /py/qstr.c
parent564963a1700bfca8f053f864ad170d4a34a26270 (diff)
py: Improve memory usage debugging; better GC AT dumping.
In unix port, mem_info(1) now prints pretty GC alloc table.
Diffstat (limited to 'py/qstr.c')
-rw-r--r--py/qstr.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/qstr.c b/py/qstr.c
index f841f1dfe..c2cfda8a3 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -30,6 +30,7 @@
#include "mpconfig.h"
#include "misc.h"
#include "qstr.h"
+#include "gc.h"
// NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings)
// ultimately we will replace this with a static hash table of some kind
@@ -220,9 +221,17 @@ void qstr_pool_info(mp_uint_t *n_pool, mp_uint_t *n_qstr, mp_uint_t *n_str_data_
*n_pool += 1;
*n_qstr += pool->len;
for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) {
+ #if MICROPY_ENABLE_GC
+ *n_str_data_bytes += gc_nbytes(*q); // this counts actual bytes used in heap
+ #else
*n_str_data_bytes += Q_GET_ALLOC(*q);
+ #endif
}
+ #if MICROPY_ENABLE_GC
+ *n_total_bytes += gc_nbytes(pool); // this counts actual bytes used in heap
+ #else
*n_total_bytes += sizeof(qstr_pool_t) + sizeof(qstr) * pool->alloc;
+ #endif
}
*n_total_bytes += *n_str_data_bytes;
}