Slide

Rob Tiffany
Mobility Architect
Microsoft Corporation
MOB401
Who am I?
Day Job
Mobility Architect in the Microsoft Mobile Global Practice
Created the Microsoft Mobile Line of Business Accelerator
Other Stuff…
Writer :: Entrepreneur :: Former Embedded MVP :: Submariner :: Disk Jockey
Session Objectives and Takeaways
Objectives
Learn how Windows Mobile 6.5 makes more memory available to applications
Learn how Windows Mobile 6.5 boosts both application & graphics performance
Learn a new pattern for .NET Compact Framework development
Key Takeaway
Create new opportunities with faster, richer, more complex games and apps that
target the consumer, science, education and line of business segments
Windows CE Memory Model
Rob Tiffany
Mobility Architect
Microsoft Corporation
Windows Mobile 6
Slot Fill Order
Slot Machine
FILE DLLs
MODULE DLLs
0
1, 0
FILE DLLs are loaded into RAM
at runtime which decreases
VM space to all slots
Slot 62 :: Shared Heaps
Slots 33-61
1 GB Large Memory Area
Memory-Mapped Files
Slots 2-32 :: Application Processes
DLL Overflow
Causes
Instability
Slot 1 :: ROM MODULE DLLs
Slot 0 :: Alias of Active Process from other Slots
FILE DLLs reduce VM space for all Processes
2 GB :: User Space
Slot 63 :: Resource-Only DLLs
Slots
Rob Tiffany
Mobility Architect
Microsoft Corporation
Windows Mobile 6.1
Slot Fill Order
Better Slot Machine
FILE DLLs
MODULE DLLs
60, 61, 0
1, 0
Slot 63 :: Resource-Only DLLs
Slot 62 :: Shared Heap Area
Slot 61 :: Read-Only FILE DLLs
Slot 60 :: Read-Only FILE DLLs
Slot 59 :: Device.exe Thread Stacks
Slots 33-58 :: Large Memory Area
Memory-Mapped Files
Slots 2-32 :: Application Processes
Slot 1 :: ROM MODULE DLLs
Convert
mshtml.dll to
FILE DLL to free
6 MB of VM
Slot 0 :: Alias of Active Process from other Slots
FILE DLLs reduce VM space for all Processes
2 GB :: User Space
DLLs used
exclusively by
one process
don’t take
space from
other
processes
Windows Mobile 6.5
Slot Fill Order
Best Slot Machine
FILE DLLs
MODULE DLLs
60, 61, 0
1, 61, 60, 0
Slot 63 :: Resource-Only DLLs
Process
Threshold
of 28
Slot 62 :: Shared Heaps
Slot 61 :: FILE + MODULE DLLs
Slot 60 :: FILE + MODULE DLLs
Slot 59 :: Device.exe Thread Stacks
Slots 33-58 :: Large Memory Area
Memory-Mapped Files
Slots 2-32 :: Application Processes
Slot 1 :: ROM MODULE DLLs
Slot 0 :: Alias of Active Process from other Slots
FILE DLLs reduce VM space for all Processes
2 GB :: User Space
Faster MODULE DLLs whose
VM is allocated at build time
instead of runtime can go
everywhere!
Windows Mobile 6.5
Faster performance
JPEG images decode faster by aligning buffer size
to 128-byte boundary needed by hardware
Glyph Cache jumps from 8KB to 72KB for English and
128KB for Asian builds to boost font rendering speed
GDI used to draw text one character at a time;
now draws the entire string in one shot
Switching Today screens and backgrounds repeatedly
does not degrade device performance
Paging Pool is set to a minimum of 15 MB
to boost application load performance
Minimum devices specs include a 400 MHz processor,
128 MB of RAM and 256 MB of ROM
Application Process Space
Native
Pushing
Down
Large Memory Area (1 GB)
Memory-Mapped Files
MapViewOfFile
Other RAM DLLs + Your DLLs
LoadLibrary
DLL Crunch
Free Virtual Memory
Heap (Object Instance Variables)
64 KB/Thread Stack (Local Method Variables)
Image of EXE file (Code + Data + Resources)
64 KB Guard Section
Pushing Up
32 MB :: Slot Space
CreateFileMapping
Application Process Space
Managed
32 MB :: Slot Space
Managed DLLs
aren’t DLLs so
they don’t
negatively
impact
any slots
In-ROM
NETCF uses
650KB less
Slot VM
Large Memory Area (1 GB)
NETCF Class Libraries
Managed EXEs + DLLs
Other Native RAM DLLs
Free Virtual Memory
GC Heap (Object Instance Variables)
IL in Call
Stack is
pulled into
Slot and JIT’d
JIT Heap (Current Call Stack)
AppDomain Heap (CLR Data Structures)
64 KB/Thread Stack (Local Method Variables)
Image of EXE file (Code + Data + Resources)
64 KB Guard Section
RAM
Allocated
though EXE
is not used
MemMaker Pattern
Managed development
Large Memory Area (1 GB)
NETCF Class Libraries
Managed EXEs
Application
Lives+inDLLs
DLLs
using System;
using System.Windows.Forms;
namespace OptimizedDLL
{
public class StartUp
{
public static void Main()
{
Application.Run(new Main());
}
}
}
32 MB :: Slot Space
Other Native RAM DLLs
Free Virtual Memory
GC Heap (Object Instance Variables)
JIT Heap (Current Call Stack)
AppDomain Heap (CLR Data Structures)
64 KB/Thread Stack (Local Method Variables)
Empty EXE file (5KB)
64 KB Guard Section
using System;
namespace OptimizedExe
{
static class Program
{
[MTAThread]
static void Main()
{
OptimizedDLL.StartUp.Main();
}
}
}
MemMaker Pattern
Rob Tiffany
Mobility Architect
Microsoft Corporation
Other ways to Breakout
Fast Cache
Store data in the 1 GB large memory area via memory mapped files
Use IPC to access an in-memory Hashtable cache running in a different slot
SQL Server Compact
Use IPC to access SQL Server Compact in a different slot
Run database with a larger Max Buffer Size setting
Send SQL commands
Receive Generic Lists of strongly-typed objects
Summary
Windows Mobile 6.5 provides your games
and apps with more virtual memory and
performance than any previous release
Incorporating the MemMaker pattern for
.NET Compact Framework development
will automatically boost the amount of
virtual memory available to your games
and apps for better performance and stability
Resources
www.microsoft.com/teched
www.microsoft.com/learning
Sessions On-Demand & Community
Microsoft Certification & Training Resources
http://microsoft.com/technet
http://microsoft.com/msdn
Resources for IT Professionals
Resources for Developers
www.microsoft.com/learning
Microsoft Certification and Training Resources
Complete an evaluation
on CommNet and enter to
win an Xbox 360 Elite!
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should
not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.