Lab 3-3: Scenario - Fixing a Memory Leak

Similar documents
Lab 3-2: Exploring the Heap

Lab 8B: Configuring the WINS Client for Windows XP Professional

EE475 Lab #3 Fall Memory Placement and Interrupts

KG-TOWER Software Download and Installation Instructions

Practice and Review Activities Software

1 Preface About this Manual Intended Audience Revision History Document Conventions Version...

_ V ST STM8 Family On-Chip Emulation. Contents. Technical Notes

Experiment #0. PC Hardware and Operating Systems

Lab 4-1: Replacing the Shell with a Custom Full Screen Browser Based UI

3 INSTALLING WINDOWS XP PROFESSIONAL

Expanding an ICM SQL Database

HI-SPEED USB 2.0 FILE TRANSFER CABLE USER MANUAL

Quick Start - OnePass Agent for Windows File System

ZwCAD Licensing Guide. Contents

Debugging code snippets in IDA Pro 5.6 using QEMU emulator Copyright 2010 Hex-Rays SA

Digi document reference number: _A

APPENDIX A. CODE COMPOSER STUDIO (CCS) v5: A BRIEF TUTORIAL FOR THE DSK6713

DOMAIN TECHNOLOGIES INC. Users Guide Version 2.0 SB-USB2. Emulator

Trace Debug Tools Version 1.2 Installation Guide

USER S MANUAL. MULTiCOM-4. USB to #4 RS-232 Serial COM Multiport. Doc No: MULTiCOM-4-UM-001

A Guide to Installing OLI Software

User Manual. LPC-StickView V3.0. for LPC-Stick (LPC2468) LPC2478-Stick LPC3250-Stick. Contents

As CCS starts up, a splash screen similar to one shown below will appear.

INSTALLATION GUIDE. ID DESIGNER PC-Based Software Installation Guide. Version 4.0

Chapter 12. Microcontroller Application Development Tools

LaCie d2 SATA II 3Gbits

USB-MIDI Driver installation and settings...1 Windows XP users... 1

New Cash Register System Quick Setup Guide. Version: XP1.0

Guide to SATA Hard Disks Installation and RAID Configuration

Developing Applications using Universal Driver 6.0x in Windows CE 6.0

OLI Engine in Aspen Hysys

SMT107 User Manual User Manual (QCF42); Version 3.0, 8/11/00; Sundance Multiprocessor Technology Ltd. 1999

Migration from HEW to e 2 studio Development Tools > IDEs

Tools Basics. Getting Started with Renesas Development Tools R8C/3LX Family

Section 0 1: Clone a BSP Create, Build, and Run a New OS Design

This is a GENERAL Servant Keeper Network Installation help sheet. If you need further assistance, please contact your network administrator.

COP 1170 Introduction to Computer Programming using Visual Basic

INSTALLATION GUIDE FOR MICROSOFT S SQL SERVER 2005 DATABASE SERVER SOFTWARE

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

AERMOD View. Course Installation & Web License Activation

Windows NT Server Printer Driver Upgrade Instructions

Galileo Print Manager Installation Guide

Hello World on the ATLYS Board. Building the Hardware

Chapter 9 Windows CE 6.0 Developer's Guide

INSTALLATION GUIDE. RAPID TAG PC-Based Software Installation Guide. Version 5.0

_ V Renesas R8C In-Circuit Emulation. Contents. Technical Notes

Micrium OS Kernel Labs

Codewarrior for ColdFire (Eclipse) 10.0 Setup

HTC Magic Required Software Update

Checking Resource Usage in Fedora (Linux)

Guide to SATA Hard Disks Installation and RAID Configuration

Lab: Advanced Installation of Windows XP. Introduction

8 MANAGING SHARED FOLDERS & DATA

SAS Installation Instructions Windows 2003, XP, 2000, NT. Workstation Installation Guidelines

EPSON PRODUCT SUPPORT BULLETIN

Lab Determining Data Storage Capacity

Lab - Data Migration in Windows

Live Viewing Using Remote Applications

Lab Install Windows 8

Quick Start Guide. Cole-Parmer USB-based Data Acquisition Software

CIS Operating Systems Non-contiguous Memory Allocation. Professor Qiang Zeng Spring 2018

Profiling Applications and Creating Accelerators

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.1 Revision: 0 Date: May 3, 2018

EXPRESS. Users Guide. Version 3.5

INSTALLATION GUIDE. RAPID TAG EVAC PC-Based Software Installation Guide. Version 5.0

1) Installing Bluetooth software for Windows (A) Place installation CD into PC and setup should launch automatically.

Adding a Boot Disk Entry to an HP Integrity rx2660

Configuring the WebDAV Folder for Adding Multiple Files to the Content Collection and Editing Them

Network Installation Guide

School-to-Home Connection Instructions

INF204x Module 2 Lab 2: Using Encrypting File System (EFS) on Windows 10 Clients

Eliminate Threading Errors to Improve Program Stability

Using Virtual EEPROM and Flash API for Renesas MCUs RX600 Series

10 MONITORING AND OPTIMIZING

Windows XP Embedded Hands-On Lab

DZ-MV350/380 Software Tutorials

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.0 Revision: 0 Date: September 18, 2017

Memory Management. Fundamentally two related, but distinct, issues. Management of logical address space resource

ScreenCreator and DirectTouch panel Error Codes

Eliminate Threading Errors to Improve Program Stability

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

USB - SERIAL CONVERTER

This chapter introduces how to use the emulator of TOPICE quickly.

Startfish driver installation is a two step process for Windows operating systems.

NEW CEIBO DEBUGGER. Menus and Commands

University of California, Davis Department of Electrical and Computer Engineering. Lab 1: Implementing Combinational Logic in the MAX10 FPGA

How to gather debug logs for support requests

TECH NOTE VICON TECHNICAL SERVICES GROUP

Macrorit Partition Expert 4.3.5

Module 5. Databases. Astro Computer Training. Page 1

KG-TOWER Software Download and Installation Instructions

Workstation Configuration

Section 2: Getting Started with a FPU Demo Project using EK-LM4F232

1 Attended Installation of Windows 2000 Server

EPSCOR and Geosciences Department Remote Desktop Server: TREX

Mobile Programming Lecture 4. Debugging

1. Open the folder called TI APPS and Emulators. 2. Open the folder called 83plus emulator

User Guide. FA5 ICE RDI Driver. User Guide. Preliminary. Jan Version 0.1

Lab 1 Introduction to Microcontroller

Windows Embedded Compact Test Kit User Guide

Transcription:

Lab 3-3: Scenario - Fixing a Memory Leak Objectives Use the Target Control utility to identify a memory leak Prerequisites Completed Lab 2-1 Estimated time to complete this lab: 30 minutes Lab Setup To complete this lab, you must have: A development workstation running Windows XP Visual Studio 2005 (Version 8) with Platform Builder plug-in A running emulator image from Lab 2-1

2 Lab 3-3 Scenario: Fix a Leaking Application Exercise 1 Virtual memory leak QA is testing the functionality of some utilities that were written for your new CE 6.0 device. The utilities initially appear to work correctly, however during the QA phase one application continues to lock up the system. A memory leak is suspected. You have been asked to take a look at the utility to identify the problem and solve it. Add the LeakingMemory subproject to your development environment 1. Using Windows Explorer, locate the Lab 3-3 Project Files on your student CD. 2. Copy the LeakingMemory folder into your OS design folder at C:\WINCE600\OSDesigns\TrainingOSDesign\TrainingOSDesign. 3. In the Solution Explorer window right click on the Subprojects folder and select Add Existing Subproject 4. Navigate to the LeakingMemory folder that you just copied. 5. Select LeakingMemory.pbpxml and click Open. Visual Studio will add the project to your current solution. 6. Configure the LeakingMemory subproject to be excluded from the image and always build and link as debug, just as you did in Lab 2-2 Exercise 1. 7. Right click the LeakingMemory subproject and select Build. Investigate the memory leak 8. Run the application by selecting Run Programs in Target menu. 9. Observe the emulator output. The following message box appears in the Device Emulator output: Note This dialog box is used to stop the application from continuing without actually breaking into the debugger, thereby allowing us to use the memory tools. This particular dialog indicates a point in the initialization sequence of the utility prior to any memory reservations. It allows us to get a picture of the initial memory usage that we can use as a basis for future comparisons.

Lab 3-3 Scenario: Fix a Leaking Application 3 10. Select Target Target Control from the Visual Studio menu. The Windows CE Command Prompt window will open. 11. At the Windows CE> prompt, type mi full. This will show memory information for all processes running on the device. 12. Locate the section for the LeakingMemory.exe process. 13. Study the virtual memory contents of the process using the following legend: Character Definition <blank> A blank space indicates a virtual page that is not currently allocated. Does not require a physical page. - Reserved but not in use. Indicates a virtual page that is currently allocated but not mapped to any physical memory. Does not require a physical page. C Code pages in ROM. Does not require a physical page. c Code pages in RAM. Requires a physical page. S Indicates a virtual page that holds a stack. Requires a physical page. P Peripheral memory (pages used to map target device memory by using VirtualAlloc). Indicates a virtual page that is used to map a range of hardware addresses. Does not require a physical page. Peripheral memory may include frame buffer memory. W Indicates a virtual page that holds read-write data. Requires a physical page. Read-write pages include global variables as well as dynamically allocated memory. O Indicates a virtual page that is used by the object store. Requires a physical page. Should only appear in the Filesys process.? Contents unknown. r Read-only data pages in RAM. Requires a physical page. Read-only data primarily comes from data items that are declared as a const type in the source code. R Read-only data pages in ROM. Does not require a physical page. Read-only data primarily comes from data items that are declared as a const type in the source code. Note: For CPUs such as ARM and SHx that do not distinguish between read-only and executable code pages in hardware, use R(r) to represent both data and code. 14. Copy the memory information for the LeakingMemory process to a temporary text file so that we can easily compare it with another run later. 15. In the emulator window, click OK in the message box. The utility will run, doing its useful work. 16. The following message box will appear in the Device Emulator output: Note This dialog box indicates the end of the utility processing. Presumably any resources that have been allocated have now been freed, and there should be no memory leaks.

4 Lab 3-3 Scenario: Fix a Leaking Application 17. At the Windows CE> prompt, type mi full. This will show the current memory information for all processes running on the device. 18. Compare the memory usage for the LeakingMemory.exe program against the one that was previously saved. 19. Click OK on the dialog box on the device, allowing it to exit. Analysis The application should have similar memory usage after it has performed its useful work and cleaned up as it did before it started. The two memory dumps should be the same. Before Memory usage for Process 'LeakingMemory.exe' pid 5e0000e 00000000: ----- 00010000: -cwc 00020000: ---------------S 00030000: W-------------- 00040000: RRRRRRRRRRRRRRRR 00050000: RRRRRRRRRRRRRRRR 00060000: RRRRRRRRRRRRRRRR 00070000: RRRR 40000000: ---------------- 40010000: -CCCCCCCCCCCCCCC 40020000: CCCCCCCCCCCCCCCC 40030000: CCCCCCCCCCCCCCCC 40040000: CCCCCCCCCCCCCCCC 40050000: CCCCCCCCCCCCCCCC 40060000: CCCCCCCCCCCCCCCC 40070000: CCCCCCCCCCCCCCCC 40080000: CCCCCCCCCCCCCCCC 40090000: W------CCCCCCC-- 400a0000: --- Page summary: code=134(2) data r/o=52 r/w=3 stack=1 reserved=63 After Memory usage for Process 'LeakingMemory.exe' pid 5e0000e 00000000: ----- 00010000: -cwc 00020000: ---------------S 00030000: W-------------- 00040000: RRRRRRRRRRRRRRRR 00050000: RRRRRRRRRRRRRRRR 00060000: RRRRRRRRRRRRRRRR 00070000: RRRR 00080000: WWWWWWWWWWWWWWWW 00090000: WWWWWWWWWWWWWWWW 40000000: ---------------- 40010000: -CCCCCCCCCCCCCCC 40020000: CCCCCCCCCCCCCCCC 40030000: CCCCCCCCCCCCCCCC 40040000: CCCCCCCCCCCCCCCC 40050000: CCCCCCCCCCCCCCCC 40060000: CCCCCCCCCCCCCCCC 40070000: CCCCCCCCCCCCCCCC 40080000: CCCCCCCCCCCCCCCC 40090000: W------CCCCCCC-- 400a0000: --- Page summary: code=134(2) data r/o=52 r/w=35 stack=1 reserved=63 However, the output of the Target Control utility shows that there is 128KB of read/write memory committed after the utility has finished that wasn t there before it started. That memory was allocated by the utility, but never released. That memory has been leaked. Fix the application

Lab 3-3 Scenario: Fix a Leaking Application 5 20. Uncomment the call to VirtualFree in the file LeakingMemory.cpp. This looks suspiciously like it might be the cause of the problem. 21. Right click on the LeakingMemory subproject and select Build. 22. Run the program again, and redo the analysis. 23. Observe that the two memory usage maps are now the same; the memory leak is gone! Note This particular leak was not all that serious and created just to illustrate the point. The memory would have been reclaimed automatically when the process exited. However, in other scenarios the leak could have been more serious. For example, a kernel mode dll could have leak that would never be recovered since the kernel process never exits. If you are continuing with the next Hands-On Lab, keep your emulated image running.