Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
System Services
Handles and Objects
Object Categories
 GDI Objects
GDI Objects

GDI objects support only one handle per object. Handles to GDI objects are private to a process. That is, only the process that created the GDI object can use the object handle.

There is a theoretical limit of 65,536 GDI handles per session. However, the maximum number of GDI handles that can be opened per session is usually lower, since it is affected by available memory.

Windows 2000:  There is a limit of 16,384 GDI handles per session.

There is also a default per-process limit of GDI handles. To change this limit, set the following registry value:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\GDIProcessHandleQuota

This value can be set to a number between 256 and 65,536.
Windows 2000:  This value can be set to a number between 256 and 16,384.

Managing GDI Objects

The following table lists the GDI objects, along with each object's creator and destroyer functions. The creator functions either create the object and an object handle or simply return the existing object handle. The destroyer functions remove the object from memory, which invalidates the object handle.

GDI objectCreator functionDestroyer function
Bitmap CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection, CreateDiscardableBitmap DeleteObject
Brush CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush DeleteObject
DC CreateDC DeleteDC, ReleaseDC
Enhanced metafile CreateEnhMetaFile DeleteEnhMetaFile
Enhanced-metafile DC CreateEnhMetaFile CloseEnhMetaFile
Font CreateFont, CreateFontIndirect DeleteObject
Memory DC CreateCompatibleDC DeleteDC
Metafile CreateMetaFile DeleteMetaFile
Metafile DC CreateMetaFile CloseMetaFile
Palette CreatePalette DeleteObject
Pen and extended pen CreatePen, CreatePenIndirect, ExtCreatePen DeleteObject
Region CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreatePolyPolygonRgn, CreateRectRgn, CreateRectRgnIndirect, CreateRoundRectRgn, ExtCreateRegion, PathToRegion DeleteObject

 

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Functions for Image, Icon, Cursor and EnhMetaFile objects      Dan at Bentley   |   Edit   |   Show History

These functions should also be listed on this page:

-- Image --

LoadImageA
LoadImageW
CopyImage

-- Icon --

CopyIcon
CreateIcon
CreateIconFromResource
CreateIconFromResourceEx
CreateIconIndirect
DestroyIcon
DuplicateIcon
ExtractAssociatedIconA
ExtractAssociatedIconW
ExtractAssociatedIconExA
ExtractAssociatedIconExW
ExtractIconA
ExtractIconW
ExtractIconExA
ExtractIconExW
LoadIconA
LoadIconW
PrivateExtractIconsA
PrivateExtractIconsW

-- Cursor --
CreateCursor
DestroyCursor
LoadCursorA
LoadCursorW
LoadCursorFromFileA
LoadCursorFromFileW

-- EnhMetaFile --
CopyEnhMetaFileA
CopyEnhMetaFileW

Tags What's this?: Add a tag
Flag as ContentBug
Windows 7 default limit      LemonadeAust   |   Edit   |   Show History
Windows 7 default limit is 10,000 too
Tags What's this?: Add a tag
Flag as ContentBug
lol      cranial.chaos_1318544351   |   Edit   |   Show History
lol
Tags What's this?: Add a tag
Flag as ContentBug
windows 7? ....same bag of fit?      cranial.chaos_1318544351 ... HunterM   |   Edit   |   Show History
honestly i brought 4GB RAM fr my laptop not knowing tht this bull *** is also there, im just a an effin normal customer tht wants to pay my money and buy a good system.... y the *** shud i hav to know about all this effin bottlenecks tht screw around with my operations? how do u increase GDI handle limit in windows 7, and does it make a difference????? im in the middle of my dissertation and pdf-xchange viewer keeps running out of resources to open files! die microsoft!$0 $0$0 $0 $0[Really, MSDN gonna let me edit this guys post??? I didn't even write this post... but I can not help myself, I think this post sucks and is not productive. I DO need to know these types of things... so users like chraniac here should not have too. I recommend using a different pdf viewer application... not Adobe's. His anger is real, his spelling is atrocious, but the direction of anger is misdirected IMO! I have said my peace... now lets see if I can "submit" this edit...]$0
Tags What's this?: Add a tag
Flag as ContentBug
Windows 7 Registry Mod Makes No Difference      will_affinity   |   Edit   |   Show History
Strangely, changing the regiistry entry to the max value and rebooting Windows 7 did not change the point in which the exception was thrown in my code. Maybe Windows 7 doesn't even use this registry entry anymore?
Tags What's this?: Add a tag
Flag as ContentBug
Can this be changed.      BMRH   |   Edit   |   Show History
65k GDI objects may seem like a lot (and it is-- I won't disagree) but is there a chance that this could be increased? At a minimum, could the default registry limit of 10k, be increased in a patch to 20k, 40k or possibly 64k? $0$0 $0 $0Updating the above mentioned registry key on a user's PC is not a good option for fixing this problem.$0
Tags What's this?: Add a tag
Flag as ContentBug
Missing bit      Nonvo ... RobSchee   |   Edit   |   Show History
what I wanted to learn was: Where are GDI objects allocated.
What memory (pool) or heap and what is the limit there?
Feel free to answer


Have a look at:
http://blogs.technet.com/b/markrussinovich/archive/2010/03/31/3322423.aspx

"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 (paged) pool. "
Tags What's this?: Add a tag
Flag as ContentBug
GDI object count      Ken VanderLinde   |   Edit   |   Show History
To programatically find the number of GDI objects, use the statement
DWORD gdiCount = GetGuiResources(hProcess, GR_GDIOBJECTS);
Tags What's this?: Add a tag
Flag as ContentBug
Windows XP and Vista - default limit      morhook ... NEMčEKOVá   |   Edit   |   Show History
The default limit in Windows XP and Vista is 10,000. You can monitor the number of GDI objects an application has from the "task manager"
Tags What's this?: Add a tag
Flag as ContentBug
Limit for XP?      Nutella   |   Edit   |   Show History
What is the maximum limit for XP? It is not disclosed in this MSDN listing.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker