Page 1 of 3

Compilation and RAM usage FAQ

Posted: Fri Dec 08, 2017 3:20 pm
by jickster
Conceptually, why does a large script run out of RAM when it is compiled?

What is the relative ratio of usage of RAM (heap vs stack)?

Codewise, which part of the code causes RAM to be depleted (and is it heap vs stack)?

Re: Compilation and RAM usage FAQ

Posted: Fri Dec 08, 2017 3:26 pm
by jickster
If I run one line (or block) at a time of a `.py` via the REPL API (as in pyexec.c:pyexec_raw_repl()), will I eliminate the issue of running out of RAM during compilation?
i.e. for N lines in a `.py` file, will my peak RAM usage during compilation be more, less, or same if I feed in one line at a time vs compile the entire N lines at once?

I understand it'll be much slower but let's say I was running out of RAM during compilation and didn't care about speed.

Re: Compilation and RAM usage FAQ

Posted: Fri Dec 08, 2017 3:32 pm
by jickster
If I compile the N lines separately, is it possible to stitch together the resulting bytecode returned by

Code: Select all

mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl);
into one mp_raw_code_t ?

Re: Compilation and RAM usage FAQ

Posted: Fri Dec 08, 2017 10:57 pm
by chrismas9
It's probably easier to pre-compile to mpy file on a PC

Re: Compilation and RAM usage FAQ

Posted: Fri Dec 08, 2017 11:26 pm
by jickster
chrismas9 wrote:It's probably easier to pre-compile to mpy file on a PC
It is but in some cases it’s not an option


Sent from my iPhone using Tapatalk

Re: Compilation and RAM usage FAQ

Posted: Sat Dec 09, 2017 7:19 am
by pythoncoder
@jickster Have you read http://docs.micropython.org/en/latest/p ... ained.html? In particular the section on the heap.

Re: Compilation and RAM usage FAQ

Posted: Sat Dec 09, 2017 1:59 pm
by jickster
pythoncoder wrote:@jickster Have you read http://docs.micropython.org/en/latest/p ... ained.html? In particular the section on the heap.

Which sections answer my questions?


Sent from my iPhone using Tapatalk

Re: Compilation and RAM usage FAQ

Posted: Sat Dec 09, 2017 5:15 pm
by deshipu
jickster wrote:
Sat Dec 09, 2017 1:59 pm
Which sections answer my questions?
Read them then you will know.

Re: Compilation and RAM usage FAQ

Posted: Sat Dec 09, 2017 7:19 pm
by jickster
deshipu wrote:
jickster wrote:
Sat Dec 09, 2017 1:59 pm
Which sections answer my questions?
Read them then you will know.
Where’s the answer to this?
jickster wrote:If I compile the N lines separately, is it possible to stitch together the resulting bytecode returned by

Code: Select all

mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl);
into one mp_raw_code_t ?


Sent from my iPhone using Tapatalk

Re: Compilation and RAM usage FAQ

Posted: Sat Dec 09, 2017 7:20 pm
by jickster
pythoncoder wrote:@jickster Have you read http://docs.micropython.org/en/latest/p ... ained.html? In particular the section on the heap.
Which section gives the answer to this question
jickster wrote:If I compile the N lines separately, is it possible to stitch together the resulting bytecode returned by

Code: Select all

mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, emit_opt, is_repl);
into one mp_raw_code_t ?


Sent from my iPhone using Tapatalk