
Debugging Memory Problems with MemoryScape™ Version 3.4 Copyright © 2010-2013 by Rogue Wave Software, Inc. All rights All other brand names are the trademarks of their respective holders. reserved. Copyright © 2007-2009 by TotalView Technologies, LLC Copyright © 1998–2007 by Etnus LLC. All rights reserved. Copyright © 1996–1998 by Dolphin Interconnect Solutions, Inc. Copyright © 1993–1996 by BBN Systems and Technologies, a divi- sion of BBN Corporation. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of Rogue Wave Software, Inc. ("Rogue Wave"). Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227- 7013. Rogue Wave has prepared this manual for the exclusive use of its cus- tomers, personnel, and licensees. The information in this manual is subject to change without notice, and should not be construed as a commitment by Rogue Wave. Rogue Wave assumes no responsibility for any errors that appear in this document. TotalView and TotalView Technologies are registered trademarks of Rogue Wave Software, Inc. TVD is a trademark of Rogue Wave. Rogue Wave uses a modified version of the Microline widget library. Under the terms of its license, you are entitled to use these modifica- tions. The source code is available at: http://www.roguewave.com/support/knowledge-base.aspx. Contents Locating Memory Problems 1 Freeing the Wrong Address.......................................... 20 Finding Memory Leaks.......................................................... 21 Checking for Problems........................................................... 2 Fixing Dangling Pointer Problems......................................... 23 Programs and Memory........................................................... 3 Dangling Pointers ...........................................................24 Behind the Scenes ................................................................. 6 Batch Scripting and Using the CLI........................................ 26 Your Program’s Data .............................................................. 7 Batch Scripting Using tvscript ..........................................26 The Data Section ............................................................. 7 Using the -dheap Command ..........................................26 The Stack ......................................................................... 7 dheap Example............................................................ 27 The Heap ....................................................................... 10 dheap........................................................................... 27 Finding Heap Allocation Problems............................... 10 Notification When free Problems Occur...................... 40 Finding Heap Deallocation Problems........................... 10 Showing Backtrace Information: dheap -backtrace: ... 41 realloc() Problems ........................................................ 11 Guarding Memory Blocks: dheap -guards ................... 41 Finding Memory Leaks ................................................. 11 Memory Reuse: dheap -hoard ..................................... 42 Starting MemoryScape ........................................................ 13 Writing Heap Information: dheap -export ................... 43 Using MemoryScape Options ........................................ 14 Filtering Heap Information: dheap -filter..................... 43 Preloading MemoryScape .............................................. 14 Checking for Dangling Pointers: dheap -is_dangling:.. 44 Understanding How Your Program is Using Memory 15 Detecting Leaks: dheap -leaks .................................... 44 Finding free() and realloc() Problems ................................... 17 Block Painting: dheap -paint ....................................... 45 Red Zones Bounds Checking: dheap -red_zones........ 45 Event and Error Notification 17 Deallocation Notification: dheap -tag_alloc ............... 48 Types of Problems ......................................................... 19 TVHEAP_ARGS ...............................................................49 Freeing Stack Memory.................................................. 19 Examining Memory............................................................... 51 Freeing bss Data........................................................... 19 Freeing Data Section Memory...................................... 19 Block Properties .............................................................52 Freeing Memory That Is Already Freed......................... 19 Memory Contents Tab................................................. 54 Tracking realloc() Problems.......................................... 20 Additional Memory Block Information ........................ 55 Debugging Memory Problems with MemoryScape Page i Filtering 56 Controlling Program Execution from a Context Menu ...83 Using Guard Blocks 56 Where to Go Next ...........................................................83 Using Red Zones................................................................... 57 Seeing Memory Usage.......................................................... 84 Using Guard Blocks and Red Zones ..................................... 58 Information Types ..........................................................84 Block Painting 58 Process and Library Reports ..........................................85 Hoarding............................................................................... 59 Chart Report ..................................................................85 Example 1: Finding a Multithreading Problem ...............59 Where to Go Next ...........................................................87 Example 2: Finding Dangling Pointer References ...........59 Using Runtime Events .......................................................... 88 Debugging with TotalView..................................................... 60 Error Notifications .........................................................88 Deallocation and Reuse Notifications ...........................90 Memory Tasks 63 Where to Go Next ...........................................................91 Graphically Viewing the Heap .............................................. 92 Getting Started ..................................................................... 64 Window Sections ............................................................92 Starting MemoryScape ...................................................64 Block Information ..........................................................93 Adding Programs and Files to MemoryScape ................66 Bottom Tabbed Areas ....................................................94 Attaching to Programs and Adding Core Files ...............67 Where to Go Next ...........................................................94 Stopping Before Finishing Execution .............................68 Obtaining Detailed Heap Information.................................. 95 Exporting Memory Data .................................................68 Heap Status Source Report ...........................................96 MemoryScape Information ............................................68 Heap Status Source Backtrace Report ..........................98 Where to Go Next ...........................................................69 Where to Go Next ...........................................................98 Adding Parallel Programs...................................................... 70 Seeing Leaks......................................................................... 99 Where to Go Next ...........................................................71 Filtering Reports ................................................................. 100 Setting MemoryScape Options ............................................ 72 Adding, Deleting, Enabling and Disabling Filters .........100 Basic Options .................................................................72 Adding and Editing Filters ............................................101 Advanced Options .........................................................74 Where to Go Next .........................................................103 Halt execution at process exit (standalone MemoryScape only) 75 Viewing Corrupted Memory................................................ 104 Halt execution on memory event or error.................... 75 Examining Corrupted Memory Blocks .........................104 Guard allocated memory.............................................. 77 Viewing Memory Contents ...........................................106 Use Red Zones to find memory access violations ....... 77 Restricting Red Zones .................................................. 78 Saving and Restoring Memory State Information .............. 107 Customizing Red Zones ............................................... 78 Procedures for Exporting and Adding Memory Data ...107 Paint memory ............................................................... 79 Using Saved State Information ....................................107 Hoard deallocated memory ......................................... 79 Where to Go Next .........................................................108 Where to Go Next
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages160 Page
-
File Size-