[PythonCE] ImportError problem

Brian Retford brian at cococorp.com
Fri Jul 8 04:20:12 CEST 2005


CE's memory model is a pile basically. All dll's are loaded into each  
process's 32mb virtual address space which reduces the amount of memory  
available for program use and for other DLL loading. It doesn't matter  
if your pda has 512mb of ram (none of them do, but just as an example),  
each process can only map 32mb of it. Wince has some other quirks that  
basically mean all dll's are loaded on 64kb boundaries, so every dll  
you import wastes on average 32kb of the already limited 32mb address  
space. I was able to get around this by a couple of things:

a) explicitly preloading the DLL in the python.exe by calling  
LoadLibrary
b) cutting things out of the dll to make it smaller
c) integrating the module directly with the python.dll, eliminating the  
dll load overhead. This is the only way I've been able to get wxPython  
to work on CE at all.

brian

On Jul 7, 2005, at 6:55 PM, Mark Doukidis wrote:

> After further googling I found an interesting article:
>
> "Windows CE .NET Advanced Memory Management"
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ 
> dncenet/html/advmemmgmt.asp
>
> Apparently DLL memory management has a few quirks.
>
> The following snipit, while referring to Pocket PC 2002, may still be  
> relevant:
>
> "With corporate applications processing vast amounts of data,
> corporate developers are forced to use large databases in their
> Windows CE applications. Usually the database engine is implemented as
> a DLL and it is usually quite large. In the example above, the
> database DLL is the troublemaking DLL C. With the combination of less
> than 16 megabytes of virtual memory space available for a Pocket PC
> 2002 application and the requirements of large, RAM-based DLLs, many
> developers are discovering that their applications will not run due to
> lack of space—not RAM, but virtual memory space."
>
> Interestingly, I have overcome this error (probably temporarily):
>
> time.strptime(datestr, '%d/%m/%y')
> File "binaries\lib\_strptime.py", line 18, in ?
> File "binaries\lib\calendar.py", line 8, in ?
> ImportError: DLL load failed: Not enough storage is available to
> complete this operation.
>
> (where line 8 in calendar.py is "import datetime", a DLL)
>
> by adding:
>
> import datetime
>
> to the beginning of my application code.
>
> The article above talks about various methods to tackle DLL problems.
> Maybe someone with a "CE" background can offer some comment in  
> "PYTHONIC" terms
> about "virtual memory space" and DLL issues.
>
> Thanks for the pointer Ulrich.
>
> Mark Doukidis
> _______________________________________________
> PythonCE mailing list
> PythonCE at python.org
> http://mail.python.org/mailman/listinfo/pythonce



More information about the PythonCE mailing list