summaryrefslogtreecommitdiff
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-08-26 15:35:26 +1000
committerDamien George <damien.p.george@gmail.com>2016-08-26 15:35:26 +1000
commit5ffe1d8dc07930818bbac6a88bec2aa5bd973402 (patch)
tree8832549d203085db88cb72d8abb6fea1c6d57d59 /py/mpconfig.h
parentd29ca28288581ca788e468528ea1680b99eb49e5 (diff)
py/gc: Add MICROPY_GC_CONSERVATIVE_CLEAR option to always zero memory.
There can be stray pointers in memory blocks that are not properly zero'd after allocation. This patch adds a new config option to always zero all allocated memory (via gc_alloc and gc_realloc) and hence help to eliminate stray pointers. See issue #2195.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 491a53746..23591e0da 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -107,6 +107,15 @@
#define MICROPY_ALLOC_GC_STACK_SIZE (64)
#endif
+// Be conservative and always clear to zero newly (re)allocated memory in the GC.
+// This helps eliminate stray pointers that hold on to memory that's no longer
+// used. It decreases performance due to unnecessary memory clearing.
+// TODO Do analysis to understand why some memory is not properly cleared and
+// find a more efficient way to clear it.
+#ifndef MICROPY_GC_CONSERVATIVE_CLEAR
+#define MICROPY_GC_CONSERVATIVE_CLEAR (1)
+#endif
+
// Support automatic GC when reaching allocation threshold,
// configurable by gc.threshold().
#ifndef MICROPY_GC_ALLOC_THRESHOLD