マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。

目次

概要

GC

アンマネージ・リソース

Marshallクラス

IDisposable インターフェイス

LOH

その他、LOH関係の参考資料

  1. The Dangers of the Large Object Heap
    http://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/
    「ラージオブジェクトヒープの危険性」サンプル作成者のページ
  2. Large Object Heap fragmentation causes OutOfmemoryException? 報告者 Rudiger Klaehn
    http://connect.microsoft.com/VisualStudio/feedback/details/521147/large-object-heap-fragmentation-causes-outofmemoryexception
    上記(1)のサンプル作成者が米Microsoftに bug として報告したMicrosoftのフィードバック用ページ
  3. .NET 航海日誌: LOH (ラージオブジェクトヒープ) でフラグメンテーションが起こる !?
    http://dotnetlogbook.blogspot.jp/2009/10/loh.html
    上記(1)を、日本語で要約したページ
  4. torutkの日記: .NETのメモリ管理と断片化問題
    http://d.hatena.ne.jp/torutk/20100529/p1

SOS.dll

WinDbg+SOS拡張によるマネージ・ライブ・デバック例

久しぶりに使ったので手順などをメモ(幾つか補足も記載)。

fileBook1.xlsx

開始

※ 同様の操作をマネージ・ダンプに対して行う事もできる。

以下はSOSデバッガ拡張コマンドの実行例。

(1)オブジェクト情報の確認方法

!DumpObj 013ac060

Name: WindowsFormsApplication1.Class1
MethodTable: 009e71fc
EEClass: 00f01fb8
Size: 20(0x14) bytes
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79332d70  4000006        4         System.Int32  1 instance        9 a
79332d70  4000007        8         System.Int32  1 instance        9 b
79332d70  4000008        c         System.Int32  1 instance        9 c
79332d70  4000009       24         System.Int32  1   static        9 x
79332d70  400000a       28         System.Int32  1   static        9 y
79332d70  400000b       2c         System.Int32  1   static        9 z

DumpObj?に指定したオブジェクトのアドレスから
メモリ情報([メモリ] ウィンドウ)を確認すると
メンバ変数の情報を確認することができる。

!DumpClass 00f01fb8

Class Name: WindowsFormsApplication1.Class1
Parent Class: 790c3ef0
Module: 009e2c5c
Method Table: 009e71fc
Vtable Slots: 4
Total Method Slots: 6
Class Attributes: 100001  
NumInstanceFields: 3
NumStaticFields: 3
      MT    Field   Offset                 Type VT     Attr    Value Name
79332d70  4000006        4         System.Int32  1 instance           a
79332d70  4000007        8         System.Int32  1 instance           b
79332d70  4000008        c         System.Int32  1 instance           c
79332d70  4000009       24         System.Int32  1   static        9 x
79332d70  400000a       28         System.Int32  1   static        9 y
79332d70  400000b       2c         System.Int32  1   static        9 z

こちらでは、インスタンス変数の値は表示されない。
また、上記のフィールド情報はilasmを使用して確認できるらしいが、情報を確認できず。

!DumpModule 009e2c5c

Attributes: PEFile 
Assembly: 001b2478
LoaderHeap: 00000000
TypeDefToMethodTableMap: 009e00c0
TypeRefToMethodTableMap: 009e00dc
MethodDefToDescMap: 009e0194
FieldDefToDescMap: 009e01d4
MemberRefToDescMap: 009e0204
FileReferencesMap: 009e02dc
AssemblyReferencesMap: 009e02e0
MetaData start address: 00402440 (4084 bytes)
!DumpMT -md 009e71fc

EEClass: 00f01fb8
Module: 009e2c5c
Name: WindowsFormsApplication1.Class1
mdToken: 02000006 BaseSize: 0x14
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 6
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
79286aa0   79104944   PreJIT System.Object.ToString()
79286ac0   7910494c   PreJIT System.Object.Equals(System.Object)
79286b30   7910497c   PreJIT System.Object.GetHashCode()
792f7510   791049a0   PreJIT System.Object.Finalize()
009ec160   009e71e4      JIT WindowsFormsApplication1.Class1..ctor()
009ec168   009e71f0      JIT WindowsFormsApplication1.Class1..cctor()

(2)メモリリークの確認方法

参考資料

Silverlightの場合

開始

WinDbgとSilverlightをインストールしておく。

オブジェクト情報の確認方法

以下WinDbgにてSilverlightのダンプファイルから、オブジェクト数を確認する手順の例。
アタッチ先を「iexplore.exe」などに設定すれば、ライブ・デバックも可能であるもよう。

Silverlight Toolkitの問題

Silverlight Toolkitにメモリリークの問題があります。

We encountered this bug too, but took a slightly different tact -- we used a weak event listener pattern.

ここの「we used:」が修正コード。

参考資料

その他

Visual Studio Enterprise Edition

Visual Studio2015 Enterprise Edition ではマネージ メモリの分析機能が
強化されており、!DumpHeap? コマンドで実現できることに近い内容が確認できる。

その他の拡張

.NET Framework アプリケーションのデバッグに有用
(ただし、サポートは提供されておらずドキュメントや公開情報も少ない状況)

psscor4

.load "C:\\Psscor4\\x86\\x86\\psscor4.dll"
!psscor4.help

mex

.load mex.dll
!mex.help

Tags: :障害対応, :性能, :デバッグ


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS