Hi~~~

I have question... my device is out of memory...
NEW DLL that not include OS can not load on memory...

i checked devhealth.exe... device.exe

--------------------------------------------------------------------------------------
Memory usage for Process 805b2880: 'device.exe' pid 2 (partly pageable)

Slot base 06000000 Section ptr 879cc000
06000000(1): ----------------
06010000(0): -CER <-- End EXE: 0x06013030
06020000(0): -----------SSSSS
06030000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06030000
06040000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06030000
06050000(0): HHHHHHHHHHHHHHH <-- Heap:0x06030000
06060000(0): ---------------S
06070000(0): --------------SS
06080000(0): ---------------S
06090000(0): --------------SS
060a0000(0): ---------------S
060b0000(0): ---------------S
060c0000(1): W
.
.
.
06dc0000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06340000
06dd0000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06340000
06de0000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06340000
06df0000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06340000
06e00000(0): HHHHHHHHHHHHHHHH <-- Heap:0x06340000
06e10000(0): HHHHHHHH-------- <-- Heap:0x06340000
06e20000(0): ?
06e30000(0): ---------------S
06e40000(0): ?
06e60000(0): ---------------S
06e70000(0): --------------SS
06e80000(0): -dddD-- <-- DLL: xxx1.dll
06e90000(0): -dddddDdD- <-- DLL: xxx2.dll +
06ea0000(0): -ddddDdd- <-- DLL: xxx3.dll
06eb0000(0): -ddddddddddddddd
06ec0000(0): dDDDDd- <-- DLL: xxx4.dll + + +
06ed0000(0): -ddddddddddddddD <-- DLL: xxx5.dll
06ee0000(0): d-
06ef0000(0): -ddddddddddDd- <-- DLL: xxx.dll
06f00000(0): -dddddddddddddDd <-- DLL: xxx.dll
06f10000(0): D- <-- DLL: xxxx.dll

When unload xxx1.dll, xxx2.dll... my NEW Dll is loaded...


I guess that solution is compact memory...


--------------------------------------------------------------------------------------
Memory usage for Process 805b2880: 'device.exe' pid 2 (partly pageable)

Slot base 06000000 Section ptr 879cc000

07920000(0): -----------dddDD <-- DLL:
07940000(0): D--- <-- DLL:
07980000(0): -dddd-dd--dddddd
07990000(0): d-dddd-ddddddd-d
079a0000(0): dddddD--D-- <-- DLL:
079c0000(0): -d-ddddddddd-D- <-- DLL:
079e0000(0): -dddD- <-- DLL:

==> not alloc 0x07900000 ~ 0x07910000
0x07950000 ~ 0x07970000...

07a10000(0): -d-ddd--d-ddD- <-- DLL:
07a20000(0): -dddd-ddd---dddd
07a30000(0): -ddddddddddD-- <-- DLL:
07a50000(0): -dddddd---------
07a60000(0): --dd-dddd--d-dDD <-- DLL:
07a70000(0): --

==> not alloc 0x07a80000 ~ 0x07af0000

07b90000(0): -ddddddddddddddd
07ba0000(0): ddddddddd--d-ddd
07bb0000(0): d--ddd-ddddddddd
07bc0000(0): dddddd--dddddDD- <-- DLL:
07bd0000(0): --------DDDDDDDD <-- DLL:
07be0000(0): DDDDDDDDDDDDDDDD <-- DLL:
07bf0000(0): DDD--D-D- <-- DLL:

==> not alloc 0x07b00000 ~ 0x07b80000

07e50000(0): ----------------
07e60000(0): --D------------- <-- DLL:
07e70000(0): -------D-D------ <-- DLL:
07ef0000(0): -------------D-- <-- DLL:

==> not alloc 0x07e00000 ~ 0x07e40000
not alloc 0x07e80000 ~ 0x07ee0000


07f00000(0): --DDDDDD-D---DD- <-- DLL:
07f10000(0): DD-DDD-DDD-DD--- <-- DLL:
07f20000(0): -D-D-D--D--DD--- <-- DLL:
07f30000(0): D---------D----- <-- DLL:
07f40000(0): -D-------------- <-- DLL:
07f50000(0): --DDDDD----DDDDD <-- DLL:
07f60000(0): DDDDDDDDDDD---DD <-- DLL:
07f70000(0): -D---------DDD-- <-- DLL:
07f80000(0): -DD--D-------DDD <-- DLL:
07f90000(0): DDDDD-DD-----D-D <-- DLL:
07fe0000(0): --------------DD <-- DLL:
07ff0000(0): -D-D--DDD------D <-- DLL:


why does not allocate continuous?
Help me... Help me...

RE: how to compact memory on WM 5.0? by MikeDimmick

MikeDimmick
Tue Jul 01 11:28:03 CDT 2008

"donlet" wrote:

> Hi~~~
>
> I have question... my device is out of memory...
> NEW DLL that not include OS can not load on memory...

First, you have to understand the Windows CE memory model. See
http://msdn.microsoft.com/en-us/library/ms836325.aspx for details.

As that article describes, this used to be a problem on Pocket PC 2002: the
eXecute In Place DLLs had filled up a lot of the 32MB process address space,
and so for CE 4.0 they added a new 32MB slot for XIP DLLs.

Fast forward three years and Windows Mobile 5.0 has grown so damn big that
it's overflowed the extra 32MB virtual address space, eaten half of the
process's slot too and the problems are repeating. In fairness, it's not
entirely Microsoft's fault: the OEMs' preinstalled DLLs are often a source of
the problem.

If you're having a problem in device.exe specifically, the issue may simply
be that there are too many device drivers installed and enabled. Each driver
normally creates a thread to handle interrupts (its interrupt service thread)
and many may create worker threads too. Each thread has to have virtual
memory reserved for its stack. The smallest stack reserve is 64KB, but you
don't get many 64KB stacks into the space available. Best case you'd get 512
of them, if no DLLs were loaded into the process slot and you didn't have any
code or dynamic memory allocation either. Neither of these is true so in
practice the limit is far lower.

Specifically your problem is that your new DLL would have to be loaded by
the OS at 0x06e70000 (or higher, depending on how big the DLL is), and that's
already occupied by a couple of pages of thread stack (assuming S indicates
Stack).

The only answer is 'do less stuff'. If you're in charge of some of the XIP
DLLs, consider removing static tables or uninitialised globals and allocating
them at runtime instead; consider removing resources from the DLL and loading
from file. You can always memory-map files in the Large Memory Area.

I'm currently fighting to cram a 760kB .NET application into a 64MB device
and it's fighting back, simply because of the size of all the other libraries
and the limited virtual address space available on the device. We're hoping
to persuade the OEM to put .NET CF 2.0 SP2 into the ROM in place of the RTM
release, which will save about 1MB. .NET DLLs may not load in the same way as
native ones, but they still result in virtual address space allocations for
metadata for loaded classes and for JITted code (about 10 times as much as
the managed heap, for this app, 3MB vs 300kB).