Cannot get to the cause of this error citing MemoryError:
-
- Posts: 7
- Joined: Mon Jun 23, 2014 10:21 am
- Contact:
Cannot get to the cause of this error citing MemoryError:
Hi all.
I am trying to run a script on a unix port of micropython.
I am trying to run a script which otherwise works well on python3.
The whole script was throwing an error so i individually started typing things on the prompt.
After import of two modules from my stack the third import is throwing a MemoryError: Exception.
Can anyone please tell what can be the source of the problem and how to circumvent it..
I am trying to run a script on a unix port of micropython.
I am trying to run a script which otherwise works well on python3.
The whole script was throwing an error so i individually started typing things on the prompt.
After import of two modules from my stack the third import is throwing a MemoryError: Exception.
Can anyone please tell what can be the source of the problem and how to circumvent it..
Re: Cannot get to the cause of this error citing MemoryError
Note that you posted question to the wrong subforum - "Micropython Development" should be used only for discussion related to the development of MicroPython itself.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
-
- Posts: 7
- Joined: Mon Jun 23, 2014 10:21 am
- Contact:
Re: Cannot get to the cause of this error citing MemoryError
Sorry for the mistake.
Re: Cannot get to the cause of this error citing MemoryError
I went ahead and moved the discussion to the General category.
As far as debugging, you can put in calls to pyb.info() and look for the GC: section.
The 102208 is the total amount of RAM available.
1856 is the number of bytes used
100352 is the number of bytes free
I haven't really looked at the gc, so I won't claim to know what the final line means.
Note that you can put calls to pyb.info() at the outermost scope while parsing the module (in case its running out of memory while importing).
For example, if I put the following in func.py and do:
and then do:
then you'll see (with just the perinent info):
So this gives you an idea of how much memory each function is taking.
As far as debugging, you can put in calls to pyb.info() and look for the GC: section.
Code: Select all
GC:
102208 total
1856 : 100352
1=37 2=17 m=16
1856 is the number of bytes used
100352 is the number of bytes free
I haven't really looked at the gc, so I won't claim to know what the final line means.
Note that you can put calls to pyb.info() at the outermost scope while parsing the module (in case its running out of memory while importing).
For example, if I put the following in func.py and do:
Code: Select all
import pyb
print("At start")
pyb.info()
def func1():
print("func1 called")
print("After func1")
pyb.info()
def func2():
print("func2 called")
print("After func2")
pyb.info()
Code: Select all
>>> import func
Code: Select all
At start
GC:
102208 total
1296 : 100912
1=33 2=13 m=8
After func1
GC:
102208 total
1328 : 100880
1=33 2=14 m=8
After func2
GC:
102208 total
1360 : 100848
1=33 2=15 m=8
-
- Posts: 7
- Joined: Mon Jun 23, 2014 10:21 am
- Contact:
Re: Cannot get to the cause of this error citing MemoryError
Thanks for the reply Dave.
There is another query.
We are meant to port a python stack on a microprocessor.
I have observed that the modules :
random
threading
_thread
collections
argparse
logging
colorsys
datetime
os
select
socket
signal
ctypes
pdb
are not supported ?
Only some very basic modules can be imported.
What is the possible solution to this problem if solvable at all.
And also it seems there is no support for wrapper and decorator .
What can be the solution if solvable?
Thanks for the prompt reply Dave(for the previous post).
Thanks again
There is another query.
We are meant to port a python stack on a microprocessor.
I have observed that the modules :
random
threading
_thread
collections
argparse
logging
colorsys
datetime
os
select
socket
signal
ctypes
pdb
are not supported ?
Only some very basic modules can be imported.
What is the possible solution to this problem if solvable at all.
And also it seems there is no support for wrapper and decorator .
What can be the solution if solvable?
Thanks for the prompt reply Dave(for the previous post).
Thanks again
Re: Cannot get to the cause of this error citing MemoryError
Unix port by default runs with a heap size ~ equal to size of heap on PyBoard, which is ~128K. Modules written for "desktop" Python are oftentimes too bloated to fit in this size. You can set heap size using "-X heapsize=<size in bytes>". You can learn about this and other options by running "micropython -h".rohanmajumdar wrote:Hi all.
I am trying to run a script on a unix port of micropython.
I am trying to run a script which otherwise works well on python3.
The whole script was throwing an error so i individually started typing things on the prompt.
After import of two modules from my stack the third import is throwing a MemoryError: Exception.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: Cannot get to the cause of this error citing MemoryError
See http://forum.micropython.org/viewtopic.php?f=5&t=70 . Contributions to that project are welcome.rohanmajumdar wrote: I have observed that the modules :
[]
are not supported ?
Only some very basic modules can be imported.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: Cannot get to the cause of this error citing MemoryError
I'm pretty confident that if you need all of those modules, then your project won't fit into the 128K of RAM that the micropython board has to offer. It sounds like you'd be better served using a Raspberry Pi or BeagleBone Black, or something else along those lines (those boards run full linux and have enough RAM to run full python).rohanmajumdar wrote:Thanks for the reply Dave.
There is another query.
We are meant to port a python stack on a microprocessor.
I have observed that the modules :
random
threading
_thread
collections
argparse
logging
colorsys
datetime
os
select
socket
signal
ctypes
pdb
are not supported ?
Only some very basic modules can be imported.
What is the possible solution to this problem if solvable at all.
-
- Posts: 7
- Joined: Mon Jun 23, 2014 10:21 am
- Contact:
Re: Cannot get to the cause of this error citing MemoryError
I am not on a pyBoard.
The amount of RAm at my disposal is 512 Kb.
I have already a ported version of my python code on the Raspberry Pi.
That code I was wishing to run with micropython.
Is there any hope...
The amount of RAm at my disposal is 512 Kb.
I have already a ported version of my python code on the Raspberry Pi.
That code I was wishing to run with micropython.
Is there any hope...