diff options
author | Peter Hinch <peter@hinch.me.uk> | 2017-11-12 06:13:45 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-11-23 11:35:58 +1100 |
commit | ec1e9a10a73d9c5c3771a5797e9eceb62475b197 (patch) | |
tree | e6930e9bd631f570fb0b7cf8fa9439ee820f256a /docs/library/micropython.rst | |
parent | df078e82136de80a6ff2d30db97a7411c45d4085 (diff) | |
download | micropython-ec1e9a10a73d9c5c3771a5797e9eceb62475b197.tar.gz micropython-ec1e9a10a73d9c5c3771a5797e9eceb62475b197.zip |
docs: Add notes on heap allocation caused by bound method refs.
Diffstat (limited to 'docs/library/micropython.rst')
-rw-r--r-- | docs/library/micropython.rst | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/docs/library/micropython.rst b/docs/library/micropython.rst index c13a7391bb..d1f923e31f 100644 --- a/docs/library/micropython.rst +++ b/docs/library/micropython.rst @@ -112,5 +112,14 @@ Functions the heap may be locked) and scheduling a function to call later will lift those restrictions. - There is a finite stack to hold the scheduled functions and `schedule` + Note: If `schedule()` is called from a preempting IRQ, when memory + allocation is not allowed and the callback to be passed to `schedule()` is + a bound method, passing this directly will fail. This is because creating a + reference to a bound method causes memory allocation. A solution is to + create a reference to the method in the class constructor and to pass that + reference to `schedule()`. This is discussed in detail here + :ref:`reference documentation <isr_rules>` under "Creation of Python + objects". + + There is a finite stack to hold the scheduled functions and `schedule()` will raise a `RuntimeError` if the stack is full. |