Home
%3CLINGO-SUB%20id%3D%22lingo-sub-723897%22%20slang%3D%22en-US%22%3EPushing%20the%20Limits%20of%20Windows%3A%20USER%20and%20GDI%20Objects%20%E2%80%93%20Part%202%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723897%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TechNet%20on%20Mar%2031%2C%202010%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2010%2F02%2F24%2F3315174.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELast%20time%20%3C%2FA%3E%20%2C%20I%20covered%20the%20limits%20and%20how%20to%20measure%20usage%20of%20one%20of%20the%20two%20key%20window%20manager%20resources%2C%20USER%20objects.%20This%20time%2C%20I%E2%80%99m%20going%20to%20cover%20the%20other%20key%20resource%2C%20GDI%20objects.%20As%20always%2C%20I%20recommend%20you%20read%20the%20previous%20posts%20before%20this%20one%2C%20because%20some%20of%20the%20limits%20related%20to%20USER%20and%20GDI%20resources%20are%20based%20on%20limits%20I%E2%80%99ve%20covered.%20Here%E2%80%99s%20a%20full%20index%20of%20my%20other%20Pushing%20the%20Limits%20of%20Windows%20posts%3A%3C%2FP%3E%0A%20%20%3CBLOCKQUOTE%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2008%2F07%2F21%2F3092070.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Physical%20Memory%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2008%2F11%2F17%2F3155406.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Virtual%20Memory%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2009%2F03%2F26%2F3211216.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Paged%20and%20Nonpaged%20Pool%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2009%2F07%2F08%2F3261309.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Processes%20and%20Threads%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2009%2F09%2F29%2F3283844.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Handles%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2010%2F02%2F24%2F3315174.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20USER%20and%20GDI%20Objects%20%E2%80%93%20Part%201%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3C%2FBLOCKQUOTE%3E%0A%20%20%3CH5%20id%3D%22toc-hId-1200153592%22%20id%3D%22toc-hId-1200154743%22%3EGDI%20Objects%3C%2FH5%3E%0A%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fms724291(VS.85).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EGDI%20objects%20%3C%2FA%3E%20represent%20graphical%20device%20interface%20resources%20like%20fonts%2C%20bitmaps%2C%20brushes%2C%20pens%2C%20and%20device%20contexts%20(drawing%20surfaces).%20As%20it%20does%20for%20USER%20objects%2C%20the%20window%20manager%20limits%20processes%20to%20at%20most%2010%2C000%20GDI%20objects%2C%20which%20you%20can%20verify%20with%20Testlimit%20using%20the%20%E2%80%93g%20switch%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22115%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_20.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121205iF8F6F0E8C3EEAF91%22%20title%3D%22image%22%20width%3D%22454%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EYou%20can%20look%20at%20an%20individual%20process%E2%80%99s%20GDI%20object%20usage%20on%20the%20Performance%20page%20of%20its%20Process%20Explorer%20process%20properties%20dialog%20and%20add%20the%20GDI%20Objects%20column%20to%20Process%20Explorer%20to%20watch%20GDI%20object%20usage%20across%20processes%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22225%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_47.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121206i74FD225EF92D779A%22%20title%3D%22image%22%20width%3D%22264%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EAlso%20like%20USER%20objects%2C%2016-bit%20interoperability%20means%20that%20USER%20objects%20have%2016-bit%20identifiers%2C%20limiting%20them%20to%2065%2C535%20per%20session.%20Here%E2%80%99s%20the%20desktop%20as%20it%20appeared%20when%20Testlimit%20hit%20that%20limit%20on%20a%20Windows%20Vista%2064-bit%20system%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22439%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_23.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121207iD54F282D157E504B%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENote%20the%20Start%20button%20on%20the%20bottom%20left%20where%20it%20belongs%2C%20but%20the%20rest%20of%20the%20task%20bar%20at%20the%20top%20of%20the%20screen.%20The%20desktop%20has%20turned%20black%20and%20the%20sidebar%20has%20lost%20most%20of%20its%20color.%20Your%20mileage%20may%20vary%2C%20but%20you%20can%20see%20that%20bizarre%20things%20start%20to%20happen%2C%20potentially%20making%20it%20impossible%20to%20interact%20with%20the%20desktop%20in%20a%20reliable%20way.%20Here%E2%80%99s%20what%20the%20display%20switched%20to%20when%20I%20pressed%20the%20Start%20button%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22439%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_24.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121208i7C4F8C4C2ACA535F%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EUnlike%20USER%20objects%2C%20GDI%20objects%20aren%E2%80%99t%20allocated%20from%20desktop%20heaps%3B%20instead%2C%20on%20Windows%20XP%20and%20Windows%20Server%202003%20systems%20that%20don%E2%80%99t%20have%20Terminal%20Services%20installed%2C%20they%20allocate%20from%20general%20paged%20pool%3B%20on%20all%20other%20systems%20they%20allocate%20from%20per-session%20session%20pool.%3C%2FP%3E%0A%20%20%3CP%3EThe%20kernel%20debugger%E2%80%99s%20%E2%80%9C!vm%204%E2%80%9D%20command%20dumps%20general%20virtual%20memory%20information%2C%20including%20session%20information%20at%20the%20end%20of%20the%20output.%20On%20a%20Windows%20XP%20system%20it%20shows%20that%20session%20paged%20pool%20is%20unused%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22207%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_29.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121209i91697D31F950177F%22%20title%3D%22image%22%20width%3D%22432%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EOn%20a%20Windows%20Server%202003%20system%20without%20Terminal%20Services%2C%20the%20output%20is%20similar%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22143%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_31.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121210i0BC05ABD443C4024%22%20title%3D%22image%22%20width%3D%22410%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20GDI%20object%20memory%20limit%20on%20these%20systems%20is%20therefore%20the%20paged%20pool%20limit%2C%20as%20described%20in%20my%20previous%20post%2C%20%3CA%20href%3D%22http%3A%2F%2Fblogs.technet.com%2Fmarkrussinovich%2Farchive%2F2009%2F03%2F26%2F3211216.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Pushing%20the%20Limits%20of%20Windows%3A%20Paged%20and%20Nonpaged%20Pool%20%3C%2FA%3E%20.%20However%2C%20when%20Terminal%20Services%20are%20installed%20on%20the%20same%20Windows%20Server%202003%20system%2C%20you%20can%20see%20from%20the%20non-zero%20session%20pool%20usage%20that%20GDI%20objects%20come%20from%20session%20pool%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22231%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_32.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121211i3E6B3EF0C3C19089%22%20title%3D%22image%22%20width%3D%22397%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20!vm%204%20command%20in%20the%20above%20output%20also%20shows%20the%20session%20paged%20pool%20maximum%20and%20session%20pool%20sizes%2C%20but%20the%20session%20paged%20pool%20maximum%20and%20session%20space%20sizes%20don%E2%80%99t%20display%20on%20Windows%20Vista%20and%20higher%20because%20they%20are%20variable.%20Session%20paged%20pool%20usage%20on%20those%20systems%20is%20capped%20by%20either%20the%20amount%20of%20address%20space%20it%20can%20grow%20to%20or%20the%20System%20Commit%20Limit%2C%20whichever%20is%20smaller.%20Here%E2%80%99s%20the%20output%20of%20the%20command%20on%20a%20Windows%207%20system%20showing%20the%20current%20session%20paged%20pool%20usage%20by%20session%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22289%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_33.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121212i61ED3348529865A4%22%20title%3D%22image%22%20width%3D%22376%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EAs%20you%E2%80%99d%20expect%2C%20the%20main%20interactive%20session%2C%20Session%201%2C%20is%20consuming%20the%20most%20session%20paged%20pool.%3C%2FP%3E%0A%20%20%3CP%3EYou%20can%20use%20the%20Testlimit%20tool%20with%20the%20%E2%80%9C%E2%80%93g%200%E2%80%9D%20switch%20to%20see%20what%20happens%20when%20the%20storage%20used%20for%20GDI%20objects%20is%20exhausted.%20The%20number%20you%20specify%20after%20the%20%E2%80%93g%20is%20the%20size%20of%20the%20GDI%20bitmap%20objects%20Testlimit%20allocates%2C%20but%20a%20size%20of%200%20has%20Testlimit%20simply%20try%20and%20allocate%20the%20largest%20objects%20possible.%20Here%E2%80%99s%20the%20result%20on%20a%2032-bit%20Windows%20XP%20system%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22113%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_38.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121213i20A46A1955D2DA71%22%20title%3D%22image%22%20width%3D%22477%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EOn%20a%20Windows%20XP%20or%20Windows%20Server%202003%20that%20doesn%E2%80%99t%20have%20Terminal%20Services%20installed%20you%20can%20use%20the%20Poolmon%20utility%20from%20Windows%20Driver%20Kit%20(WDK)%20to%20see%20the%20GDI%20object%20allocations%20by%20their%20pool%20tag.%20The%20output%20of%20Poolmon%20the%20while%20Testlimit%20was%20exhausting%20paged%20pool%20on%20the%20WIndows%20XP%20system%20looks%20like%20this%20when%20sorted%20by%20bytes%20allocated%20(type%20%E2%80%98b%E2%80%99%20in%20the%20Poolmon%20display%20to%20sort%20by%20bytes%20allocated)%2C%20by%20inference%20indicating%20that%20Gh05%20is%20the%20tag%20for%20bitmap%20objects%20on%20Windows%20Server%202003%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22158%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_37.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121214i3AF87E97D538B57B%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EOn%20a%20Windows%20Server%202003%20system%20with%20Terminal%20Services%20installed%2C%20and%20on%20Windows%20Vista%20and%20higher%2C%20you%20have%20to%20use%20Poolmon%20with%20the%20%2Fs%20switch%20to%20specify%20which%20session%20you%20want%20to%20view.%20Here%E2%80%99s%20Testlimit%20executed%20on%20a%20Windows%20Server%202003%20system%20that%20has%20Terminal%20Services%20installed%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22125%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_35.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121215i2F7380C950EEA265%22%20title%3D%22image%22%20width%3D%22472%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20command%20%E2%80%9Cpoolmon%20%2Fs1%E2%80%9D%20shows%20the%20tags%20with%20the%20largest%20allocation%20contributing%20for%20Session%201.%20You%20can%20see%20the%20Gh15%20tag%20at%20the%20top%2C%20showing%20that%20a%20different%20pool%20tag%20is%20being%20used%20for%20bitmap%20allocations%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22148%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_44.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121216iB3FB6E7D8E887742%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENote%20how%20Testlimit%20was%20able%20to%20allocate%20around%2058%20MB%20of%20bitmap%20data%20(that%20number%20doesn%E2%80%99t%20account%20for%20GDI%E2%80%99s%20internal%20overhead%20for%20a%20bitmap%20object)%20on%20the%20Windows%20XP%20system%2C%20but%20only%2010MB%20on%20the%20Windows%20Server%202003%20system.%20The%20smaller%20number%20comes%20from%20the%20fact%20that%20session%20pool%20on%20the%20Windows%20Server%202003%20Terminal%20Server%20system%20is%20only%2032%20MB%2C%20which%20is%20about%20the%20amount%20of%20memory%20Poolmon%20shows%20attributed%20to%20the%20Gh15%20tag.%20The%20output%20of%20%E2%80%9C!vm%204%E2%80%9D%20confirms%20that%20session%20pool%20for%20Session1%20is%20been%20consumed%20and%20that%20subsequent%20attempts%20to%20allocate%20GDI%20objects%20from%20session%20pool%20have%20failed%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22251%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_40.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121217i58EE730C741FE15D%22%20title%3D%22image%22%20width%3D%22421%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EYou%20can%20also%20use%20the%20!poolused%20kernel%20debugger%20command%20to%20look%20at%20session%20pool%20usage.%20First%2C%20switch%20to%20the%20correct%20session%20by%20using%20the%20.process%20command%20with%20the%20%2Fp%20switch%20and%20the%20address%20of%20a%20process%20object%20that%E2%80%99s%20connected%20to%20the%20session.%20To%20see%20what%20processes%20are%20running%20in%20a%20particular%20session%2C%20use%20the%20!sprocess%20command.%20Here%E2%80%99s%20the%20output%20of%20!poolmon%20on%20the%20same%20Windows%20Server%202003%20system%2C%20where%20the%20%E2%80%9Cc%E2%80%9D%20option%20to%20!poolused%20has%20it%20sort%20the%20output%20by%20allocated%20bytes%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20alt%3D%22image%22%20border%3D%220%22%20height%3D%22430%22%20original-url%3D%22http%3A%2F%2Fblogs.technet.com%2Fblogfiles%2Fmarkrussinovich%2FWindowsLiveWriter%2FPushingtheLimitsofWindowsUSERandGDIObjec_85FB%2Fimage_thumb_45.png%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F121218iA6BBDCEC0311243A%22%20title%3D%22image%22%20width%3D%22554%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EUnfortunately%2C%20there%E2%80%99s%20no%20public%20mapping%20between%20the%20window%20manager%E2%80%99s%20heap%20tags%20and%20the%20objects%20they%20represent%2C%20but%20the%20kernel%20debugger%E2%80%99s%20!poolused%20command%20uses%20the%20triage.ini%20file%20from%20the%20debugger%E2%80%99s%20installation%20directory%20to%20print%20more%20descriptive%20information%20about%20a%20tag.%20The%20command%20reports%20that%20Gh15%20is%20GDITAG_HMGR_SPRITE_TYPE%2C%20which%20is%20only%20slightly%20more%20helpful%2C%20but%20others%20are%20more%20clear.%3C%2FP%3E%0A%20%20%3CP%3EFortunately%2C%20most%20GDI%20and%20USER%20object%20issues%20are%20limited%20to%20a%20particular%20process%20hitting%20the%20per-process%2010%2C000%20object%20limit%20and%20so%20more%20advanced%20investigation%20to%20figure%20out%20what%20process%20is%20responsible%20for%20exhausting%20session%20pool%20or%20allocating%20GDI%20objects%20to%20exhaust%20paged%20pool%20is%20unnecessary.%3C%2FP%3E%0A%20%20%3CP%3ENext%20time%20I%E2%80%99ll%20take%20a%20look%20at%20System%20Page%20Table%20Entries%20(System%20PTEs)%2C%20another%20key%20system%20resource%20that%20can%20has%20limits%20that%20can%20be%20hit%2C%20especially%20on%20Remote%20Desktop%20sessions%20on%20Windows%20Server%202003%20systems.%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-723897%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TechNet%20on%20Mar%2031%2C%202010%20Last%20time%2C%20I%20covered%20the%20limits%20and%20how%20to%20measure%20usage%20of%20one%20of%20the%20two%20key%20window%20manager%20resources%2C%20USER%20objects.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-723897%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMark%20Russinovich%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on TechNet on Mar 31, 2010

Last time , I covered the limits and how to measure usage of one of the two key window manager resources, USER objects. This time, I’m going to cover the other key resource, GDI objects. As always, I recommend you read the previous posts before this one, because some of the limits related to USER and GDI resources are based on limits I’ve covered. Here’s a full index of my other Pushing the Limits of Windows posts:

Pushing the Limits of Windows: Physical Memory

Pushing the Limits of Windows: Virtual Memory

Pushing the Limits of Windows: Paged and Nonpaged Pool

Pushing the Limits of Windows: Processes and Threads

Pushing the Limits of Windows: Handles

Pushing the Limits of Windows: USER and GDI Objects – Part 1

GDI Objects

GDI objects represent graphical device interface resources like fonts, bitmaps, brushes, pens, and device contexts (drawing surfaces). As it does for USER objects, the window manager limits processes to at most 10,000 GDI objects, which you can verify with Testlimit using the –g switch:

image

You can look at an individual process’s GDI object usage on the Performance page of its Process Explorer process properties dialog and add the GDI Objects column to Process Explorer to watch GDI object usage across processes:

image

Also like USER objects, 16-bit interoperability means that USER objects have 16-bit identifiers, limiting them to 65,535 per session. Here’s the desktop as it appeared when Testlimit hit that limit on a Windows Vista 64-bit system:

image

Note the Start button on the bottom left where it belongs, but the rest of the task bar at the top of the screen. The desktop has turned black and the sidebar has lost most of its color. Your mileage may vary, but you can see that bizarre things start to happen, potentially making it impossible to interact with the desktop in a reliable way. Here’s what the display switched to when I pressed the Start button:

image

Unlike USER objects, GDI objects aren’t allocated from desktop heaps; instead, on Windows XP and Windows Server 2003 systems that don’t have Terminal Services installed, they allocate from general paged pool; on all other systems they allocate from per-session session pool.

The kernel debugger’s “!vm 4” command dumps general virtual memory information, including session information at the end of the output. On a Windows XP system it shows that session paged pool is unused:

image

On a Windows Server 2003 system without Terminal Services, the output is similar:

image

The GDI object memory limit on these systems is therefore the paged pool limit, as described in my previous post, Pushing the Limits of Windows: Paged and Nonpaged Pool . However, when Terminal Services are installed on the same Windows Server 2003 system, you can see from the non-zero session pool usage that GDI objects come from session pool:

image

The !vm 4 command in the above output also shows the session paged pool maximum and session pool sizes, but the session paged pool maximum and session space sizes don’t display on Windows Vista and higher because they are variable. Session paged pool usage on those systems is capped by either the amount of address space it can grow to or the System Commit Limit, whichever is smaller. Here’s the output of the command on a Windows 7 system showing the current session paged pool usage by session:

image

As you’d expect, the main interactive session, Session 1, is consuming the most session paged pool.

You can use the Testlimit tool with the “–g 0” switch to see what happens when the storage used for GDI objects is exhausted. The number you specify after the –g is the size of the GDI bitmap objects Testlimit allocates, but a size of 0 has Testlimit simply try and allocate the largest objects possible. Here’s the result on a 32-bit Windows XP system:

image

On a Windows XP or Windows Server 2003 that doesn’t have Terminal Services installed you can use the Poolmon utility from Windows Driver Kit (WDK) to see the GDI object allocations by their pool tag. The output of Poolmon the while Testlimit was exhausting paged pool on the WIndows XP system looks like this when sorted by bytes allocated (type ‘b’ in the Poolmon display to sort by bytes allocated), by inference indicating that Gh05 is the tag for bitmap objects on Windows Server 2003:

image

On a Windows Server 2003 system with Terminal Services installed, and on Windows Vista and higher, you have to use Poolmon with the /s switch to specify which session you want to view. Here’s Testlimit executed on a Windows Server 2003 system that has Terminal Services installed:

image

The command “poolmon /s1” shows the tags with the largest allocation contributing for Session 1. You can see the Gh15 tag at the top, showing that a different pool tag is being used for bitmap allocations:

image

Note how Testlimit was able to allocate around 58 MB of bitmap data (that number doesn’t account for GDI’s internal overhead for a bitmap object) on the Windows XP system, but only 10MB on the Windows Server 2003 system. The smaller number comes from the fact that session pool on the Windows Server 2003 Terminal Server system is only 32 MB, which is about the amount of memory Poolmon shows attributed to the Gh15 tag. The output of “!vm 4” confirms that session pool for Session1 is been consumed and that subsequent attempts to allocate GDI objects from session pool have failed:

image

You can also use the !poolused kernel debugger command to look at session pool usage. First, switch to the correct session by using the .process command with the /p switch and the address of a process object that’s connected to the session. To see what processes are running in a particular session, use the !sprocess command. Here’s the output of !poolmon on the same Windows Server 2003 system, where the “c” option to !poolused has it sort the output by allocated bytes:

image

Unfortunately, there’s no public mapping between the window manager’s heap tags and the objects they represent, but the kernel debugger’s !poolused command uses the triage.ini file from the debugger’s installation directory to print more descriptive information about a tag. The command reports that Gh15 is GDITAG_HMGR_SPRITE_TYPE, which is only slightly more helpful, but others are more clear.

Fortunately, most GDI and USER object issues are limited to a particular process hitting the per-process 10,000 object limit and so more advanced investigation to figure out what process is responsible for exhausting session pool or allocating GDI objects to exhaust paged pool is unnecessary.

Next time I’ll take a look at System Page Table Entries (System PTEs), another key system resource that can has limits that can be hit, especially on Remote Desktop sessions on Windows Server 2003 systems.