reducing the memory footprint of drivers and apps n.
Skip this Video
Download Presentation
Reducing the memory footprint of drivers and apps

Loading in 2 Seconds...

play fullscreen
1 / 31

Reducing the memory footprint of drivers and apps - PowerPoint PPT Presentation

  • Uploaded on

HW-141T. Reducing the memory footprint of drivers and apps. Rahul Nair Program Manager Joe Laughlin Principal Software Developer Microsoft Corporation. Agenda. Platform approach to reducing memory usage Understanding memory usage Classification of memory t ypes

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Reducing the memory footprint of drivers and apps' - garren

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
reducing the memory footprint of drivers and apps

Reducing the memory footprint of drivers and apps

Rahul Nair

Program Manager

Joe Laughlin

Principal Software Developer

Microsoft Corporation


Platform approach to reducing memory usage

Understanding memory usage

Classification of memory types

Using Windows Performance Analyzer

Guidelines and best practices

You’ll leave with

  • How to understand the memory impact of an app/driver
  • How to identify areas of opportunity for optimizing memory usage
Memory is a key resource, and optimizing memory usage ensures a consistent and responsive user experience.
why is memory important
Why is memory important?
  • Being leaner and more efficient in terms of memory footprint
    • Ensures a responsive and smooth app experience
    • Shapes user perception regarding resource utilization
    • Improves scalability across a range of hardware platforms
    • Reduces power consumption

Platform approach to

Reducing Memory Usage

optimizing memory footprint
Optimizing memory footprint
  • Multi-pronged strategy:
    • Windows
      • Reductions in idle memory usage
      • Platform investments that improve general memory usage
      • Targeted optimizations for key user scenarios
      • Telemetry to help identify additional OS opportunities
    • Partners and Ecosystem
      • Telemetry to help identify opportunities
      • Memory analysis tools
      • Education and outreach


memory usage


key concepts
Key concepts
  • App cost in totality
  • Impact to system responsiveness
  • Short term vs. long term impact
  • Allocation patterns
app cost in totality
App cost in totality


Holistic view of memory usage

Breadth of impact

  • Direct usage
  • Files
  • Allocations

Frequency of use

  • Memory usage of an app/driver
  • Indirect usage

Targeted platform and audience

  • System memory resources
  • Subsystems
composition of physical m emory
Composition of physical memory

Composition of Physical Memory

In Use


  • Process working sets
  • Standby Cache
  • Non Paged Memory
  • Free

Critical for system responsiveness

  • Modified
windows memory m anagement
Windows memory management


Standby Cache

In Use

Hard Fault


Soft Fault


Close /Unmap File



Working Sets






system responsiveness and the standby cache
System responsiveness and the Standby Cache
  • Standby Cache holds contents that were recently accessed by apps and is critical for ensuring system responsiveness
    • Enables more efficient utilization of physical memory
    • Cost of accessing memory from RAM is much lower than the cost of a Disk IO
  • Important Considerations:
    • The higher your persistent memory usage  Lesser the availability of RAM for other purposes
    • Large transient usage can push out more valuable contents
short t erm vs long t erm i mpact
Short term vs. long term impact
  • Understand the memory usage of your Scenario/Component in terms of
    • Transient or Peak Impact
    • Persistent or Steady-state Impact
  • Important considerations
    • Frequency of peaks will have significant impact on standby cache
    • Focus on memory usage associated with common user scenarios

Memory Usage




example peak vs steady s tate
Example: peak vs. steady state
  • Why is the steady state memory usage growing for this scenario?
  • Why is there a transient peak in memory usage for this part of the scenario?
allocation patterns
Allocation Patterns

Steady state


  • Fragmentation
    • Occurs when unused ‘gaps’ arise between blocks of allocated memory
    • You can no longer allocate a block of memory as big as the available free memory
    • Due to mixing allocations of longer lifetimes with shorter lifetimes
  • Important considerations
    • Focus on grouping together allocations of similar lifetime and size to minimize fragmentation


Steady state



basic memory classification
Basic memory classification
  • File


HighLevel Classification

  • Heap
  • VirtualAlloc
  • Paged Pool
  • Pageable
  • Dynamic
  • Non Paged Pool
  • Non Paged Driver code
  • Non-Pageable
  • Executables (exe, dll)
  • Data files (txt, db)
  • Driver Images (.sys)
dynamic user m ode a llocations



(NT Heap)

Low Fragmentation Heap (LFH)

  • Services allocations of all sizes, until allocation thresholds are reached
  • Composed of sub-segments that service allocations of fixed size once allocation thresholds are met
  • Allocations above 512KB/1MB are allocated using VirtualAlloc
Dynamic user mode allocations
  • The Windows heap is a memory pool created at start-up that processes use to dynamically allocate memory as needed
  • Windows heap has three basic dynamic allocation areas:
dynamic kernel m ode a llocations

Paged Pool

  • NonPaged Pool
  • NX NonPaged Pool
  • Session Pool
  • Allocations that can be paged out of memory to the pagefile
  • Allocations that are guaranteed to reside in physical memory
  • New for Windows 8: Non executable pages used for these allocations
  • Allocations that are associated to a particular user session
Dynamic kernel mode allocations
  • Pool is the kernel mode equivalent of heap
    • Memory resource that the OS and device drivers use to store their data structures
  • The Windows Pool has four basic allocation areas:
memory data
Memory data
  • Windows Performance Analyzer presents data in the form of graphs and summary tables
  • Memory data:
  • Context
  • Basic data
  • Metadata
  • Size - How much?
  • Lifetime - How long?
  • Allocationstack - By who?
  • Address - Where?

Transient - Short lived

Outstanding - Alive at a given point in time

  • Based on Memory Type
  • Example
  • Heap Handle
  • Pool Type
  • Pool tag
general philosophy
General philosophy
  • Understand peaks and steady state

Manage memory allocations efficiently

  • Understand allocation patterns
  • Questions
  • When do you need to allocate memory?
  • When do you release memory?
  • Considerations
  • Be lazy in allocating and diligent in releasing
  • Avoid excessive pre-allocation that you might never use
  • Questions
  • What do you need long term for normal usage?
  • What is scenario specific?
  • Considerations
  • Minimize steady state
  • Optimize for your most frequent and most important user scenarios
    • Questions
    • How frequently do you access a particular allocation?
    • Would your patterns result in fragmentation?
    • Considerations
    • Group together allocations with similar lifetime
  • Reuse temporary allocations
  • Avoid frequent allocation/deallocation

Use the Windows Performance Analyzer to analyze and identify areas of optimization

best practices for driver developers
Best practices for Driver Developers

Optimizing memory footprint

  • Understand pool usage
  • Focus on the most frequent usage and important scenarios like System Boot

Best practices

  • Focus on non-paged memory usage
  • Avoid excessive pre-allocation that you might never use
  • Layout data structures efficiently and reuse them when possible
  • Avoid mixing long lived allocations with short lived ones which can cause fragmentation
  • Test and validate to eliminate memory leaks
  • Move non-paged allocations to the more secure non-executable non-paged pool
best practices for a pp d evelopers
Best practices for app developers

Optimizing memory footprint

  • Understand your dynamic memory usage
  • Focus on the most frequent and important user scenarios
  • Understand the new Metro style app model and implications

Best practices

  • Defer memory allocations until you need to use them, especially during app launch
  • Ensure that scenario specific allocations are freed as soon as possible
  • Reuse dynamic allocations/temporary buffers whenever possible
  • Avoid frequent mapping and unmapping of Virtual Address space
  • Avoid mixing long lived allocations with short lived ones which can cause fragmentation
key takeaways
Key takeaways
    • Memory is a shared resource and good citizenship is important
    • Has a direct impact on system responsiveness
  • Approach to reducing memory usage should include
    • Optimizing for long term and short term impact
    • Efficiently managing memory allocations
    • Optimal allocation patterns
  • Use the tools to actively invest in improving your memory usage
for more information
For more information

Related sessions

Documentation & articles

  • Driver Development Tools
  • Windows Hardware Dev Center
  • Windows Dev Center
  • HW-59T Improving performance with the Windows Performance Toolkit
  • HW-927P Understanding pool usage using Windows Performance Analyzer
  • HW-928P Understanding heap data Using Windows Performance Analyzer
  • HW-977P Understanding VirtualAlloc usage using Windows Performance Analyzer
  • HW-925P Customizing WPA Trace Views
  • HW-926P Introduction to the new WPA user interface
feedback and q uestions http forums dev windows com session f eedback http bldw in sessionfeedback
thank you

Feedback and questions

Session feedback


© 2011 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.