Dec 17, 2015
GAMECHANGER: Break Out of the 32 MB Memory Barrier with the Microsoft .NET Compact Framework and Windows Mobile 6.5
Rob TiffanyMobility ArchitectMicrosoft CorporationWMB306
Who Am I?
Day Job
Mobility Architect in the Microsoft Mobile Global Practice
Created the Microsoft Mobile Line of Business Accelerator
Writer :: Entrepreneur :: Former Embedded MVP :: Submariner :: DJ
Other Stuff…
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
Slot Fill Order
FILE DLLs MODULE DLLs
0 1, 0
Slot 63 :: Resource-Only DLLs
Slot 0 :: Alias of Active Process from Other SlotsOverflow DLLs Reduce VM Space for All Processes
Slots 2-32 :: Application Processes
Slots 33-611 GB Large Memory Area
Memory-Mapped Files
2 G
B ::
Use
r Spa
ce
FILE DLLs are loaded into every slot which decreases VM space
to all slots
DLL Overflow Causes
Instability
MODULE DLLs are
4K page-aligned
instead of 64K due
to ARM architecture
saving 9MB of VM
Slot 62 :: Shared Heaps
Windows Mobile 6Slot Machine
Slot 1 :: ROM FILE DLLs + MODULE DLLs
Slot 63 :: Resource-Only DLLs
Slot 1 :: ROM FILE DLLs + MODULE DLLs
Slots 2-32 :: Application Processes
Slots 33-58 :: Large Memory AreaMemory-Mapped Files
2 G
B ::
Use
r Spa
ce
Slot 62 :: Shared Heap Area
Slot 61 :: Read-Only FILE DLLs
Slot 60 :: Read-Only FILE DLLs
Slot 59 :: Device.exe Thread Stacks
Extra 64 MB of VM
Extra 8 MB of VM for Device Drivers
Slot 0 :: Alias of Active Process from Other SlotsOverflow DLLs Reduce VM Space for All Processes
Convert mshtml.dll to
FILE DLL to free 6 MB of VM
DLLs used exclusively by one process don’t take space from
other processes
Windows Mobile 6.1Better Slot Machine
Slot Fill Order
FILE DLLs MODULE DLLs
60, 61, 0 1, 0
Slot 63 :: Resource-Only DLLs
Slot 1 :: ROM FILE DLLs + MODULE DLLs
Slots 2-32 :: Application Processes
Slots 33-58 :: Large Memory AreaMemory-Mapped Files
2 G
B ::
Use
r Spa
ce
Slot 62 :: Shared Heaps
Slot 61 :: FILE + MODULE DLLs
Slot 60 :: FILE + MODULE DLLs
Slot 59 :: Device.exe Thread Stacks
Slot 0 :: Alias of Active Process from Other SlotsOverflow DLLs Reduce VM Space for All Processes
Faster MODULE DLLs whose VM is allocated at build time instead of runtime can go everywhere!
Process Threshold
of 28
Windows Mobile 6.5Best Slot Machine
Slot Fill Order
FILE DLLs MODULE DLLs
60, 61, 0 1, 61, 60, 0
Windows Mobile 6.5Faster performanceJPEG 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 SpaceNative
64 KB Guard Section
Image of EXE file (Code + Data + Resources)
64 KB/Thread Stack (Local Method Variables)
Heap (Object Instance Variables)
Free Virtual Memory
Other DLLs + Your DLLs
Push
ing
Up
Push
ing
Dow
n
Large Memory Area (1 GB)Memory-Mapped Files
LoadLibrary
MapViewOfFileCreateFileMapping
32 M
B ::
Slot
Spa
ceBreakout
DLL Crunch
64 KB Guard Section
Image of EXE file (Code + Data + Resources)
AppDomain Heap (CLR Data Structures)
JIT Heap (Current Call Stack)
64 KB/Thread Stack (Local Method Variables)
GC Heap (Object Instance Variables)
Free Virtual Memory
Other Native DLLs
Large Memory Area (1 GB)NETCF Class LibrariesManaged EXEs + DLLs
RAM Allocated
though EXE is not used
IL in Call Stack is
pulled into Slot and JIT’d
32
MB
:: Sl
ot S
pace
Managed DLLs aren’t DLLs so they don’t negatively impact any slots
Application Process SpaceManaged
Breakout
In-ROM NETCF uses 650KB less
Slot VM
64 KB Guard Section
Empty EXE file (5KB)
AppDomain Heap (CLR Data Structures)
JIT Heap (Current Call Stack)
64 KB/Thread Stack (Local Method Variables)
GC Heap (Object Instance Variables)
Free Virtual Memory
Other Native DLLs
Large Memory Area (1 GB)NETCF Class LibrariesManaged EXEs + DLLs
32 M
B ::
Slot
Spa
ce
Application Lives in DLLs
using System; namespace OptimizedExe { static class Program { [MTAThread] static void Main() { OptimizedDLL.StartUp.Main(); } } }
using System; using System.Windows.Forms;
namespace OptimizedDLL { public class StartUp { public static void Main() { Application.Run(new Main()); } } }
MemMaker PatternManaged development
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
Use IPC to access SQL Server Compact in a different slot
SQL Server Compact
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
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learningMicrosoft Certification and Training Resources
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
Windows Mobile® ResourcesTechNet TechCenter – System Center Mobile Device Manager 2008 http://technet.microsoft.com/scmdm
TechNet TechCenter – Windows Mobile http://technet.microsoft.com/windowsmobile
MSDN Center – Windows Mobilehttp://msdn.microsoft.com/windowsmobile
Webcasts and Podcasts for IT – Windows Mobilehttp://www.microsoft.com/events/series/msecmobility.aspx
General Information – Windows Mobilehttp://www.windowsmobile.com
General Information – System Center Mobile Device Manager 2008http://www.windowsmobile.com/mobiledevicemanager
Windows Marketplace Developer Portalhttp://developer.windowsmobile.com
Windows Mobile® is giving away Blackjack IIs !
Stop by the Windows Mobile Technical Learning Center to learn how to enter
© 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.