Discussion:
Increasing GDI Object Limits
(too old to reply)
EMS Solutions
2004-07-28 08:19:01 UTC
Permalink
Greetings all,

I am after some confiirmation of GDI limitations for Windows 2000 vs Windows 2003 running Terminal Server. I have been advised the following facts on the Microsoft Partner newgroups:

"The total number of GDI objects on a system is 16384 before Windows XP;
it's 65536 for Windows XP and above.

The default limit for both User and GDI objects is 10,000 on Windows 2000
and Windows XP."

If the total number of GDI objects for a system before XP
is 16384, would that then mean that a Windows 2000
Terminal Server in application mode running 10 concurrent
users only has a total of 16,384 allowed GDI objects to
share between those 10 users?

Can I assume then that a Windows 2003 Terminal Server in
application mode running 10 concurrent users would have a
higher total limit of 65,536 GDI objects to share between
it's users?

We are experiencing some application problems (VB6 with
SQL Server) on rare occasions in W2K Terminal Server that
seem to be related GDI limits. Based on what I have been advised here, moving to Windows 2003 Server may allow a much
higher limit and eliminate the problem.

Any help on GDI limitations much appreciated.

Regards,

Chris Matthews
Network Manager
EMS Solutions
Ralph
2004-07-28 12:16:48 UTC
Permalink
Post by EMS Solutions
Greetings all,
I am after some confiirmation of GDI limitations for Windows 2000 vs
Windows 2003 running Terminal Server. I have been advised the following
Post by EMS Solutions
"The total number of GDI objects on a system is 16384 before Windows XP;
it's 65536 for Windows XP and above.
The default limit for both User and GDI objects is 10,000 on Windows 2000
and Windows XP."
If the total number of GDI objects for a system before XP
is 16384, would that then mean that a Windows 2000
Terminal Server in application mode running 10 concurrent
users only has a total of 16,384 allowed GDI objects to
share between those 10 users?
Can I assume then that a Windows 2003 Terminal Server in
application mode running 10 concurrent users would have a
higher total limit of 65,536 GDI objects to share between
it's users?
We are experiencing some application problems (VB6 with
SQL Server) on rare occasions in W2K Terminal Server that
seem to be related GDI limits. Based on what I have been advised here,
moving to Windows 2003 Server may allow a much
Post by EMS Solutions
higher limit and eliminate the problem.
Any help on GDI limitations much appreciated.
Regards,
Chris Matthews
Network Manager
EMS Solutions
I am surprised, considering the source, but it appears you have been given
bad information. Or miss-understood their replies.

Perhaps they were referring to the initial "default" size of the GDI/User
heaps. The numbers you are quoting were valid before Win98/Me, but not
since. Win2k+ system resource heaps are essentially unlimited (based on
available memory, hardware, etc.)

Moving to XP may resolve your problem (using the latest 'n greatest is
seldom a bad idea), but I don't believe you are having any trouble with GDI
heaps.

-ralph
Robert
2004-07-28 12:22:38 UTC
Permalink
Not true, in my experience. At 10.000 my application would not get another
GDI or USER object handle. It couldn't even display a message box to report
the error! (And that was W2K).

Robert
Post by EMS Solutions
Post by EMS Solutions
Greetings all,
I am after some confiirmation of GDI limitations for Windows 2000 vs
Windows 2003 running Terminal Server. I have been advised the following
Post by EMS Solutions
"The total number of GDI objects on a system is 16384 before Windows XP;
it's 65536 for Windows XP and above.
The default limit for both User and GDI objects is 10,000 on Windows 2000
and Windows XP."
If the total number of GDI objects for a system before XP
is 16384, would that then mean that a Windows 2000
Terminal Server in application mode running 10 concurrent
users only has a total of 16,384 allowed GDI objects to
share between those 10 users?
Can I assume then that a Windows 2003 Terminal Server in
application mode running 10 concurrent users would have a
higher total limit of 65,536 GDI objects to share between
it's users?
We are experiencing some application problems (VB6 with
SQL Server) on rare occasions in W2K Terminal Server that
seem to be related GDI limits. Based on what I have been advised here,
moving to Windows 2003 Server may allow a much
Post by EMS Solutions
higher limit and eliminate the problem.
Any help on GDI limitations much appreciated.
Regards,
Chris Matthews
Network Manager
EMS Solutions
I am surprised, considering the source, but it appears you have been given
bad information. Or miss-understood their replies.
Perhaps they were referring to the initial "default" size of the GDI/User
heaps. The numbers you are quoting were valid before Win98/Me, but not
since. Win2k+ system resource heaps are essentially unlimited (based on
available memory, hardware, etc.)
Moving to XP may resolve your problem (using the latest 'n greatest is
seldom a bad idea), but I don't believe you are having any trouble with GDI
heaps.
-ralph
Ralph
2004-07-28 14:31:41 UTC
Permalink
Post by Robert
Not true, in my experience. At 10.000 my application would not get another
GDI or USER object handle. It couldn't even display a message box to report
the error! (And that was W2K).
Robert
Being "unlimited" does not mean you can not reach a limit at some point. It
only means there is not a defined limit on any particular system resource or
heap as there was before Win32.

The OP was providing numbers that were suspiciously identical to Win16
numbers and apparently was told that if he upgraded his platform he would
magically get a bigger heap. This is not true.

Also, does that mean that when your application starts up - the system
automatically allocates an "unlimited" amount of memory for all system
resources? Of course not. Each 'heap' gets some finite size, (a size that
varies for each resource), and that size is increased as more resources are
required. Your application likely failed at 10,000 because it couldn't
allocate any more memory, NOT because there was some magical limitation of
10,000 of objects.

[Sidenote: Win32 also provides a additional heaps of different kinds of
"resources". In Win16 there was a limited amount for "GDI" and "USER" heaps.
Win32 provides separate heaps for physical pens/brushes, logical
pens/brushes, fonts, regions, Device Contexts, timers, etc.]

Obviously there is a constraint on the total amount of memory you can
allocate on any system. Even the state-of-the-art computer on the Enterprise
(Star Trek NG) has been shown to reach some finite limitation at some point.

-ralph
Post by Robert
Post by EMS Solutions
Post by EMS Solutions
Greetings all,
I am after some confiirmation of GDI limitations for Windows 2000 vs
Windows 2003 running Terminal Server. I have been advised the following
Post by EMS Solutions
"The total number of GDI objects on a system is 16384 before Windows XP;
it's 65536 for Windows XP and above.
The default limit for both User and GDI objects is 10,000 on Windows
2000
Post by EMS Solutions
Post by EMS Solutions
and Windows XP."
If the total number of GDI objects for a system before XP
is 16384, would that then mean that a Windows 2000
Terminal Server in application mode running 10 concurrent
users only has a total of 16,384 allowed GDI objects to
share between those 10 users?
Can I assume then that a Windows 2003 Terminal Server in
application mode running 10 concurrent users would have a
higher total limit of 65,536 GDI objects to share between
it's users?
We are experiencing some application problems (VB6 with
SQL Server) on rare occasions in W2K Terminal Server that
seem to be related GDI limits. Based on what I have been advised here,
moving to Windows 2003 Server may allow a much
Post by EMS Solutions
higher limit and eliminate the problem.
Any help on GDI limitations much appreciated.
Regards,
Chris Matthews
Network Manager
EMS Solutions
I am surprised, considering the source, but it appears you have been given
bad information. Or miss-understood their replies.
Perhaps they were referring to the initial "default" size of the GDI/User
heaps. The numbers you are quoting were valid before Win98/Me, but not
since. Win2k+ system resource heaps are essentially unlimited (based on
available memory, hardware, etc.)
Moving to XP may resolve your problem (using the latest 'n greatest is
seldom a bad idea), but I don't believe you are having any trouble with
GDI
Post by EMS Solutions
heaps.
-ralph
Ralph
2004-07-28 15:25:16 UTC
Permalink
To amplify...

When system resource heaps are iniatially allocated they are sized with a
specific block of memory. As additional resouces of the same type is
allocated, the heaps are not increased just to manage the additional
resource, but are expanded by a pre-determined "best case" block of memory.

In the case of memory failures this causes the various heaps to appear sized
with "magic" numbers. This, IMHO, has helped perpetuate the myth that system
resouces have a built-in limitation.

These "magic" sizes are the result of memory allocation schemes and not of
pre-defined limits.

-ralph
Post by Robert
Post by Robert
Not true, in my experience. At 10.000 my application would not get another
GDI or USER object handle. It couldn't even display a message box to
report
Post by Robert
the error! (And that was W2K).
Robert
Being "unlimited" does not mean you can not reach a limit at some point. It
only means there is not a defined limit on any particular system resource or
heap as there was before Win32.
The OP was providing numbers that were suspiciously identical to Win16
numbers and apparently was told that if he upgraded his platform he would
magically get a bigger heap. This is not true.
Also, does that mean that when your application starts up - the system
automatically allocates an "unlimited" amount of memory for all system
resources? Of course not. Each 'heap' gets some finite size, (a size that
varies for each resource), and that size is increased as more resources are
required. Your application likely failed at 10,000 because it couldn't
allocate any more memory, NOT because there was some magical limitation of
10,000 of objects.
[Sidenote: Win32 also provides a additional heaps of different kinds of
"resources". In Win16 there was a limited amount for "GDI" and "USER" heaps.
Win32 provides separate heaps for physical pens/brushes, logical
pens/brushes, fonts, regions, Device Contexts, timers, etc.]
Obviously there is a constraint on the total amount of memory you can
allocate on any system. Even the state-of-the-art computer on the Enterprise
(Star Trek NG) has been shown to reach some finite limitation at some point.
-ralph
Post by Robert
Post by EMS Solutions
Post by EMS Solutions
Greetings all,
I am after some confiirmation of GDI limitations for Windows 2000 vs
Windows 2003 running Terminal Server. I have been advised the following
Post by EMS Solutions
"The total number of GDI objects on a system is 16384 before Windows
XP;
Post by Robert
Post by EMS Solutions
Post by EMS Solutions
it's 65536 for Windows XP and above.
The default limit for both User and GDI objects is 10,000 on Windows
2000
Post by EMS Solutions
Post by EMS Solutions
and Windows XP."
If the total number of GDI objects for a system before XP
is 16384, would that then mean that a Windows 2000
Terminal Server in application mode running 10 concurrent
users only has a total of 16,384 allowed GDI objects to
share between those 10 users?
Can I assume then that a Windows 2003 Terminal Server in
application mode running 10 concurrent users would have a
higher total limit of 65,536 GDI objects to share between
it's users?
We are experiencing some application problems (VB6 with
SQL Server) on rare occasions in W2K Terminal Server that
seem to be related GDI limits. Based on what I have been advised here,
moving to Windows 2003 Server may allow a much
Post by EMS Solutions
higher limit and eliminate the problem.
Any help on GDI limitations much appreciated.
Regards,
Chris Matthews
Network Manager
EMS Solutions
I am surprised, considering the source, but it appears you have been
given
Post by Robert
Post by EMS Solutions
bad information. Or miss-understood their replies.
Perhaps they were referring to the initial "default" size of the
GDI/User
Post by Robert
Post by EMS Solutions
heaps. The numbers you are quoting were valid before Win98/Me, but not
since. Win2k+ system resource heaps are essentially unlimited (based on
available memory, hardware, etc.)
Moving to XP may resolve your problem (using the latest 'n greatest is
seldom a bad idea), but I don't believe you are having any trouble with
GDI
Post by EMS Solutions
heaps.
-ralph
Karl E. Peterson
2004-07-28 16:11:58 UTC
Permalink
Hi Ralph --
Post by Ralph
I am surprised, considering the source, but it appears you have been
given bad information. Or miss-understood their replies.
Perhaps they were referring to the initial "default" size of the
GDI/User heaps. The numbers you are quoting were valid before
Win98/Me, but not since. Win2k+ system resource heaps are essentially
unlimited (based on available memory, hardware, etc.)
Not at all. There's a *very* hard limit on GDI objects. More info:

http://www.windevnet.com/documents/s=7290/wdj9902b/9902b.htm
username: busy, password: boss (thanks, www.bugmenot.com!)

To see how just two instances of an application with a GDI leak can totally
destablize a system, see:

http://www.fawcette.com/archives/premier/mgznarch/vbpj/2000/02feb00/ap0200/ap0200.asp

That all said, I'm not aware of how XP may or may not have increased the size of this
handle table, but it definitely applies to NT4 and W2K.

Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Ralph
2004-07-28 18:53:01 UTC
Permalink
Post by Karl E. Peterson
Hi Ralph --
Post by Ralph
I am surprised, considering the source, but it appears you have been
given bad information. Or miss-understood their replies.
Perhaps they were referring to the initial "default" size of the
GDI/User heaps. The numbers you are quoting were valid before
Win98/Me, but not since. Win2k+ system resource heaps are essentially
unlimited (based on available memory, hardware, etc.)
http://www.windevnet.com/documents/s=7290/wdj9902b/9902b.htm
username: busy, password: boss (thanks, www.bugmenot.com!)
To see how just two instances of an application with a GDI leak can totally
http://www.fawcette.com/archives/premier/mgznarch/vbpj/2000/02feb00/ap0200/ap0200.asp
Post by Karl E. Peterson
That all said, I'm not aware of how XP may or may not have increased the size of this
handle table, but it definitely applies to NT4 and W2K.
Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Your reputation precludes me from saying out-right you are wrong, and
convinces me to take a closer look at the details of Win2k system resource
management. However, I don't think you are correct concerning Win2k and NT4
architectures.

Your sources all refer to NT 4.0 with hints that it 'might' be the same with
NT 5.0. NT4 shares a close architecture with Win98/Me, but is different from
Win2k. I am aware that Win98/Me represents a middle ground between the
tightly limited resources of the original Win3x architecture and the
unlimited resources of Win2k. In my previous post I bunched all the changes
under the heading of "Win32" and "Win16". This was misleading and a mistake
on my part. To truly quanitify the differences one needs to refer to a
specific platform (NT4, Win2k, XP) and not the API.

For example, in Win98/Me and NT 4:
Windows/Menu handles are limited to 32kb.
Listbox Items are limited to 32kb (while listbox data is unlimited).
Device Contexts are limited to 16kb.
All these limitations have been removed with Win2k.

So I don't believe your last comment, "definitely applies to NT4 and W2K" is
correct.

Of course this all comes back to the rather puzzling question of - How can
you have "unlimited" resources (user and gdi items) within a "limited"
resource (system resources)? The answer has to be - You can't. I never said,
or at least hope I never said, that you can't run out of any specific
resource - only that there is not a predefined, pre-set limit.

Or in the OP's case - there is no way to increase any particular heap,
beyond increasing system resources (RAM, Disk Space, Memory, ...). Even that
has a limitation. As system resources are already "unlimited" in Win2k, I
fail to see how moving to the "unlimited" resources of XP would improve the
situation.

But we are perhaps missing the bigger issue here, for the original OP and
Robert. They wrote stuff that blew up believing that they ran across some
evil platform limitation. The implication being - if only M$ hadn't stuck in
that barrier, damn it, everything would be rosy. What I should have said -
No! You didn't hit a road-block, you designed a memory hogging SUV that
couldn't stay on the road. <g>

-ralph
Karl E. Peterson
2004-07-28 20:45:47 UTC
Permalink
Hi Ralph --
Post by Ralph
Your reputation precludes me from saying out-right you are wrong, and
convinces me to take a closer look at the details of Win2k system
resource management.
Appreciated.
Post by Ralph
However, I don't think you are correct
concerning Win2k and NT4 architectures.
Your sources all refer to NT 4.0 with hints that it 'might' be the
same with NT 5.0.
I spent considerable time confirming it with folks inside Microsoft, given one of my
sources was me! <g> We escalated it directly to the NT team, who were (at the time)
building NT5.
Post by Ralph
NT4 shares a close architecture with Win98/Me, but
is different from Win2k.
Where do you get this idea from? NT4 was a direct descendent of NT 3.x, which of
course pre-dated Win95.
Post by Ralph
I am aware that Win98/Me represents a middle
ground between the tightly limited resources of the original Win3x
architecture and the unlimited resources of Win2k.
Resources are definitely not unlimited, no matter what, so that's a phrase best
forgotten.
Post by Ralph
In my previous
post I bunched all the changes under the heading of "Win32" and
"Win16". This was misleading and a mistake on my part.
Not _that_ misleading, as 9x GDI was heavily based on Win16, and had 16-bit code
laced throughout.
Post by Ralph
To truly
quanitify the differences one needs to refer to a specific platform
(NT4, Win2k, XP) and not the API.
Windows/Menu handles are limited to 32kb.
Listbox Items are limited to 32kb (while listbox data is
unlimited). Device Contexts are limited to 16kb.
Do you have any cites indicating those limits applied to NT4? (I think I could
fairly easily show the Listbox Items one is incorrect, as I still have an NT4 box
available. If you can suggest tests for the others, I'd be willing to try those, as
well.)
Post by Ralph
All these limitations have been removed with Win2k.
I think they were "removed" at NT 3.1, actually.
Post by Ralph
So I don't believe your last comment, "definitely applies to NT4 and
W2K" is correct.
Well, that second article I pointed you to has a test project you can use to
determine whether that's true.
Post by Ralph
Of course this all comes back to the rather puzzling question of -
How can you have "unlimited" resources (user and gdi items) within a
"limited" resource (system resources)? The answer has to be - You
can't.
Right.
Post by Ralph
I never said, or at least hope I never said, that you can't
run out of any specific resource - only that there is not a
predefined, pre-set limit.
GDI handles definitely are. Perhaps it's now user-configurable, via a registry
setting, but there is a very hard limit to the table size. If you want to
experiment, see:

\HKEY_LOCAL_MACHINE
\SOFTWARE
\Microsoft
\NT
\CurrentVersion
\Windows
ProcessHandleQuota:REG_DWORD

That setting throttles the number of handles any given process can consume. It
wouldn't be hard to determine the system limit by starting multiple leaky processes.
Post by Ralph
But we are perhaps missing the bigger issue here, for the original OP
and Robert. They wrote stuff that blew up believing that they ran
across some evil platform limitation. The implication being - if only
M$ hadn't stuck in that barrier, damn it, everything would be rosy.
What I should have said - No! You didn't hit a road-block, you
designed a memory hogging SUV that couldn't stay on the road. <g>
Well yeah, there is that, too. <g>

Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Ralph
2004-07-28 22:37:34 UTC
Permalink
Post by Karl E. Peterson
Hi Ralph --
Post by Ralph
Your reputation precludes me from saying out-right you are wrong, and
convinces me to take a closer look at the details of Win2k system
resource management.
Appreciated.
Post by Ralph
However, I don't think you are correct
concerning Win2k and NT4 architectures.
Your sources all refer to NT 4.0 with hints that it 'might' be the
same with NT 5.0.
I spent considerable time confirming it with folks inside Microsoft, given one of my
sources was me! <g> We escalated it directly to the NT team, who were (at the time)
building NT5.
Post by Ralph
NT4 shares a close architecture with Win98/Me, but
is different from Win2k.
Where do you get this idea from? NT4 was a direct descendent of NT 3.x, which of
course pre-dated Win95.
Post by Ralph
I am aware that Win98/Me represents a middle
ground between the tightly limited resources of the original Win3x
architecture and the unlimited resources of Win2k.
Resources are definitely not unlimited, no matter what, so that's a phrase best
forgotten.
Post by Ralph
In my previous
post I bunched all the changes under the heading of "Win32" and
"Win16". This was misleading and a mistake on my part.
Not _that_ misleading, as 9x GDI was heavily based on Win16, and had 16-bit code
laced throughout.
Post by Ralph
To truly
quanitify the differences one needs to refer to a specific platform
(NT4, Win2k, XP) and not the API.
Windows/Menu handles are limited to 32kb.
Listbox Items are limited to 32kb (while listbox data is
unlimited). Device Contexts are limited to 16kb.
Do you have any cites indicating those limits applied to NT4? (I think I could
fairly easily show the Listbox Items one is incorrect, as I still have an NT4 box
available. If you can suggest tests for the others, I'd be willing to try those, as
well.)
Post by Ralph
All these limitations have been removed with Win2k.
I think they were "removed" at NT 3.1, actually.
Post by Ralph
So I don't believe your last comment, "definitely applies to NT4 and
W2K" is correct.
Well, that second article I pointed you to has a test project you can use to
determine whether that's true.
Post by Ralph
Of course this all comes back to the rather puzzling question of -
How can you have "unlimited" resources (user and gdi items) within a
"limited" resource (system resources)? The answer has to be - You
can't.
Right.
Post by Ralph
I never said, or at least hope I never said, that you can't
run out of any specific resource - only that there is not a
predefined, pre-set limit.
GDI handles definitely are. Perhaps it's now user-configurable, via a registry
setting, but there is a very hard limit to the table size. If you want to
\HKEY_LOCAL_MACHINE
\SOFTWARE
\Microsoft
\NT
\CurrentVersion
\Windows
ProcessHandleQuota:REG_DWORD
That setting throttles the number of handles any given process can consume. It
wouldn't be hard to determine the system limit by starting multiple leaky processes.
Post by Ralph
But we are perhaps missing the bigger issue here, for the original OP
and Robert. They wrote stuff that blew up believing that they ran
across some evil platform limitation. The implication being - if only
M$ hadn't stuck in that barrier, damn it, everything would be rosy.
What I should have said - No! You didn't hit a road-block, you
designed a memory hogging SUV that couldn't stay on the road. <g>
Well yeah, there is that, too. <g>
Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
I wish I could find some "authoritive" cites that backs up the "unlimited"
feature of Win2K. (I did a brief search before responding before - to
compare to my notes)
Unfortunately everything found so far is less than what I would consider
"authoritative". M$ tends to just say something along the lines of "the old
limits of Win3 is no longer true and Win2k is unlimited", without much
evidence or detail behind it.

A good example of a 3rd party article:
http://www.apptools.com/rants/resources.php.
While interesting and definitely quotes "Me" correctly. (More by lucky
inclusion of keywords than support I believe. <g>) I would certainly not
call it "authoritative".

My own notes are old and the 'sources' reduced to a summary. I am ill
equiped at the moment to do the required investigation. But I will not give
up yet. (that german potty training again) As I believe most was derived
from M$ sources as well. So I will get back to you, with either an humbling
ok, or a gloat, or something in between. <g>

I agree, that there HAS to be some finite limit somewhere. If nothing else,
the OP and Robert ran into a "limit". So perhaps the question merely becomes
one of semantics and the definition of a "limit" and at what level we are
talking about. Analogous, for example, to the size of a pathname.

In a file system driver the limit is 65534 bytes, but the WinAPI internally
usually doesn't handle anything much bigger than 1k. Some API calls will
take one that is 2k. Some 3rd party utilities manage pathnames of 4k and
larger. Unicode mucks up the numbers some more.

So what is the "limit" on pathnames? The "official" file system size of 64k
or some de facto limitation imposed by the tools we use? What if M$ decides
that no one, at least no one sane, would ever create a pathname that long -
thus declare that pathnames are officially "unlimited"?

[As for my remarks, concerning NT4 and Win98: Yes, I am aware that NT
predates the latter, but Win98 in many ways incorportated the architecture
of NT - remember Win98 was to be the "blend". I still believe that User/GDI
system resource management in the two are similar. Blanket comparisons are
of course dangerous. As you pointed out Win98 is also a "blend" of Win3.
(There are even stark differences in some components between Win98 and
Win98SE.)]

Thanks for the thoughtful reply.
-ralph
EMS Solutions
2004-07-29 09:50:21 UTC
Permalink
Thanks to everyone for the replies. Hard to know who is right or wrong, all I can go with is my observations. Based on some more testing today, what Robert stated seems to be consistent with my environment (Windows 2000 Professional Desktop, PIII 750, 512MB RAM).

If I fire up a few of the GDI hungry apps, flick between the many screens available within the application and watch the GDI handles grow and grow, you can guarantee a serious GDI failure at around 10,000 GDI handles. Every time! That's a pretty firm limit in my book.

Tomorrow I hope to use the little app (provided in one of your links)which will consume GDI handles until break point. I will test this on a Windows 2000 Terminal Server, then re-test with the same server loaded with Windows 2003 Server. I'll let you know the results. Basically I just want to be sure the GDI limitation is noticeably higher on Windows 2003/XP.

Just to frighten you all - our app which seems to tip the O/S over the edge can consume as many as 6,000 GDI handles on it's own! Our development team are telling me there is not a great deal else we can do with VB6 and the amount of Grids and Forms needed in the specification. Ie, we need this many handles to provide the functionally rich application and also give good performance when switching between screens. We use a few 3rd party Grids, Tree Views and List Bars, so perhaps there is nothing we can do... Let me know if you think otherwise. I agree from a network Admin point of view that perhaps the O/S is not to blame, but the application's hungry GDI usage.

Cheers,

Chris Matthews
Network Manager
EMS Solutions
EMS Solutions
2004-07-29 09:51:04 UTC
Permalink
Thanks to everyone for the replies. Hard to know who is right or wrong, all I can go with is my observations. Based on some more testing today, what Robert stated seems to be consistent with my environment (Windows 2000 Professional Desktop, PIII 750, 512MB RAM).

If I fire up a few of the GDI hungry apps, flick between the many screens available within the application and watch the GDI handles grow and grow, you can guarantee a serious GDI failure at around 10,000 GDI handles. Every time! That's a pretty firm limit in my book.

Tomorrow I hope to use the little app (provided in one of your links)which will consume GDI handles until break point. I will test this on a Windows 2000 Terminal Server, then re-test with the same server loaded with Windows 2003 Server. I'll let you know the results. Basically I just want to be sure the GDI limitation is noticeably higher on Windows 2003/XP.

Just to frighten you all - our app which seems to tip the O/S over the edge can consume as many as 6,000 GDI handles on it's own! Our development team are telling me there is not a great deal else we can do with VB6 and the amount of Grids and Forms needed in the specification. Ie, we need this many handles to provide the functionally rich application and also give good performance when switching between screens. We use a few 3rd party Grids, Tree Views and List Bars, so perhaps there is nothing we can do... Let me know if you think otherwise. I agree from a network Admin point of view that perhaps the O/S is not to blame, but the application's hungry GDI usage.

Cheers,

Chris Matthews
Network Manager
EMS Solutions
Karl E. Peterson
2004-07-29 20:30:08 UTC
Permalink
Post by EMS Solutions
If I fire up a few of the GDI hungry apps, flick between the many
screens available within the application and watch the GDI handles
grow and grow, you can guarantee a serious GDI failure at around
10,000 GDI handles. Every time! That's a pretty firm limit in my
book.
16K should be the upper limit. How are you finding that number?
Post by EMS Solutions
Tomorrow I hope to use the little app (provided in one of your
links)which will consume GDI handles until break point.
Here's a really simple one:

Option Explicit

Private Declare Function CreatePen _
Lib "gdi32" ( _
ByVal nPenStyle As Long, _
ByVal nWidth As Long, _
ByVal crColor As Long) As Long

Private Declare Function DeleteObject _
Lib "gdi32" ( _
ByVal hObject As Long) As Long

Private hPen() As Long

Private Sub Command1_Click()
Dim i As Long
ReDim hPen(1 To &H8000&) As Long
For i = 1 To UBound(hPen)
hPen(i) = CreatePen(0, 0, i * 16)
If hPen(i) Then
If i Mod &H40 = 0 Then
Me.Caption = i & " pens created so far..."
End If
Else
Me.Caption = "Had to bail out on pen #" & i
Exit For
End If
Next i
End Sub

Private Sub Command2_Click()
Dim i As Long
For i = 1 To UBound(hPen)
If hPen(i) <> 0 Then
Call DeleteObject(hPen(i))
End If
Next i
End Sub

Private Sub Form_Load()
Set Me.Icon = Nothing
End Sub

I'd recommend setting the Cancel property on Command2 to True, so you can clean up
after trashing the video display. <g> Of course, that won't happen until you fire
off a second instance.
Post by EMS Solutions
I will test
this on a Windows 2000 Terminal Server, then re-test with the same
server loaded with Windows 2003 Server. I'll let you know the
results. Basically I just want to be sure the GDI limitation is
noticeably higher on Windows 2003/XP.
Please let us know!
Post by EMS Solutions
Just to frighten you all - our app which seems to tip the O/S over
the edge can consume as many as 6,000 GDI handles on it's own! Our
development team are telling me there is not a great deal else we can
do with VB6 and the amount of Grids and Forms needed in the
specification. Ie, we need this many handles to provide the
functionally rich application and also give good performance when
switching between screens. We use a few 3rd party Grids, Tree Views
and List Bars, so perhaps there is nothing we can do... Let me know
if you think otherwise. I agree from a network Admin point of view
that perhaps the O/S is not to blame, but the application's hungry
GDI usage.
Saying there's nothing you can do is a total cop-out. There's lots you can do, but
it wouldn't be easy, especially with similar performance. I don't think I could
recommend an app that was written like this. Then again, if the customer specifies a
pig, who am I to deliver a greyhound?

Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
EMS Solutions
2004-08-02 08:25:01 UTC
Permalink
Thanks Karl,

I have finished my testing and it looks like Windows 2003 Server and Windows XP offer much more room to move when GDI handles are concerned compared to Windows 2000. I did manage to find hard limits on repeated tests of each O/S.

Note that I used the application KillNT.exe from

http://www.fawcette.com/archives/premier/mgznarch/vbpj/2000/02feb00/ap0200/ap0200.asp

This was very useful in proving the upper GDI object limits of each O/S.\

See below for results.

Thanks very much for all your assistance. You were a great help and I think we've got a good result.
Post by Karl E. Peterson
Post by EMS Solutions
If I fire up a few of the GDI hungry apps, flick between the many
screens available within the application and watch the GDI handles
grow and grow, you can guarantee a serious GDI failure at around
10,000 GDI handles. Every time! That's a pretty firm limit in my
book.
16K should be the upper limit. How are you finding that number?
You are right - it was 16K and not 10K sorry. Interesting that using more than around 14,000 in W2K and 40,000 in W2003/XP causes forms to overlap and not refresh properly as the O/S struggles with all the GDI's.
Post by Karl E. Peterson
Post by EMS Solutions
I will test
this on a Windows 2000 Terminal Server, then re-test with the same
server loaded with Windows 2003 Server. I'll let you know the
results. Basically I just want to be sure the GDI limitation is
noticeably higher on Windows 2003/XP.
Please let us know!
Windows 2000 definitely has a GDI object limit per user of 16,000 handles. I could repeatedly 'break' the O/S once I exceeded this number of handles. Anything below this was fine. I noted that in a Windows 2000 Terminal Server situation, there is no server-wide GDI Object limit. That is, many users can login to the Terminal Server and use an undetermined amount of GDI objects in total (I saw a combined excess of 80,000 GDI's on W2K and W2003 servers), however no SINGLE user can take more than their 16,000 limit within a session without failure. System failure after exceeding the GDI limit is also isolated to the Terminal Server session and not server wide, which is nice.

I then re-tested everything on Windows 2003 Server and found the upper limit for a single user is definitely 65,536 GDI objects. Again the server has no apprent limit for total number of GDI's for all users combined. Looks like upgrading to Windows 2003 Terminal Server and Windows XP is the answer for us and our clients to avoid these errors.
Post by Karl E. Peterson
Post by EMS Solutions
Just to frighten you all - our app which seems to tip the O/S over
the edge can consume as many as 6,000 GDI handles on it's own! Our
development team are telling me there is not a great deal else we can
do with VB6 and the amount of Grids and Forms needed in the
specification. Ie, we need this many handles to provide the
functionally rich application and also give good performance when
switching between screens. We use a few 3rd party Grids, Tree Views
and List Bars, so perhaps there is nothing we can do... Let me know
if you think otherwise. I agree from a network Admin point of view
that perhaps the O/S is not to blame, but the application's hungry
GDI usage.
Saying there's nothing you can do is a total cop-out. There's lots you can do, but
it wouldn't be easy, especially with similar performance. I don't think I could
recommend an app that was written like this. Then again, if the customer specifies a
pig, who am I to deliver a greyhound?
Hehe... this app definitely isn't a greyhound! It was pretty much customer specified and now we are seeing the poor results... We are looking at ways to improve it and the bulk of the GDI memory usage has been traced back to our extensive use of functionally rich grids (using TrueDBGrid 7.0). These grids can be sorted, grouped coloured and there are around 12 of them in this one app! Removing these grids from the exe has seen an 80% improvement in GDI usage and also a dramatic memory usage reduction. There is more work to do here but at least these findings have given us a workaround with the O/S to prevent the errors we were seeing by hitting the GDI limits on W2K.
Post by Karl E. Peterson
Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Ralph
2004-08-02 16:44:40 UTC
Permalink
Post by EMS Solutions
Thanks Karl,
I have finished my testing and it looks like Windows 2003 Server and
Windows XP offer much more room to move when GDI handles are concerned
compared to Windows 2000. I did manage to find hard limits on repeated tests
of each O/S.
Post by EMS Solutions
Note that I used the application KillNT.exe from
http://www.fawcette.com/archives/premier/mgznarch/vbpj/2000/02feb00/ap0200/ap0200.asp
Post by EMS Solutions
This was very useful in proving the upper GDI object limits of each O/S.\
See below for results.
Thanks very much for all your assistance. You were a great help and I
think we've got a good result.
Post by EMS Solutions
Post by Karl E. Peterson
Post by EMS Solutions
If I fire up a few of the GDI hungry apps, flick between the many
screens available within the application and watch the GDI handles
grow and grow, you can guarantee a serious GDI failure at around
10,000 GDI handles. Every time! That's a pretty firm limit in my
book.
16K should be the upper limit. How are you finding that number?
You are right - it was 16K and not 10K sorry. Interesting that using more
than around 14,000 in W2K and 40,000 in W2003/XP causes forms to overlap and
not refresh properly as the O/S struggles with all the GDI's.
Post by EMS Solutions
Post by Karl E. Peterson
Post by EMS Solutions
I will test
this on a Windows 2000 Terminal Server, then re-test with the same
server loaded with Windows 2003 Server. I'll let you know the
results. Basically I just want to be sure the GDI limitation is
noticeably higher on Windows 2003/XP.
Please let us know!
Windows 2000 definitely has a GDI object limit per user of 16,000 handles.
I could repeatedly 'break' the O/S once I exceeded this number of handles.
Anything below this was fine. I noted that in a Windows 2000 Terminal Server
situation, there is no server-wide GDI Object limit. That is, many users can
login to the Terminal Server and use an undetermined amount of GDI objects
in total (I saw a combined excess of 80,000 GDI's on W2K and W2003 servers),
however no SINGLE user can take more than their 16,000 limit within a
session without failure. System failure after exceeding the GDI limit is
also isolated to the Terminal Server session and not server wide, which is
nice.
Post by EMS Solutions
I then re-tested everything on Windows 2003 Server and found the upper
limit for a single user is definitely 65,536 GDI objects. Again the server
has no apprent limit for total number of GDI's for all users combined. Looks
like upgrading to Windows 2003 Terminal Server and Windows XP is the answer
for us and our clients to avoid these errors.
Post by EMS Solutions
Post by Karl E. Peterson
Post by EMS Solutions
Just to frighten you all - our app which seems to tip the O/S over
the edge can consume as many as 6,000 GDI handles on it's own! Our
development team are telling me there is not a great deal else we can
do with VB6 and the amount of Grids and Forms needed in the
specification. Ie, we need this many handles to provide the
functionally rich application and also give good performance when
switching between screens. We use a few 3rd party Grids, Tree Views
and List Bars, so perhaps there is nothing we can do... Let me know
if you think otherwise. I agree from a network Admin point of view
that perhaps the O/S is not to blame, but the application's hungry
GDI usage.
Saying there's nothing you can do is a total cop-out. There's lots you can do, but
it wouldn't be easy, especially with similar performance. I don't think I could
recommend an app that was written like this. Then again, if the customer specifies a
pig, who am I to deliver a greyhound?
Hehe... this app definitely isn't a greyhound! It was pretty much customer
specified and now we are seeing the poor results... We are looking at ways
to improve it and the bulk of the GDI memory usage has been traced back to
our extensive use of functionally rich grids (using TrueDBGrid 7.0). These
grids can be sorted, grouped coloured and there are around 12 of them in
this one app! Removing these grids from the exe has seen an 80% improvement
in GDI usage and also a dramatic memory usage reduction. There is more work
to do here but at least these findings have given us a workaround with the
O/S to prevent the errors we were seeing by hitting the GDI limits on W2K.
Post by EMS Solutions
Post by Karl E. Peterson
Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Thanks for the feedback.

I was mistaken (Hear that Karl. <smile>).

M$'s definition of "unlimited" was exactly what they were saying - "The
individual limits impossed by 'Earlier' platforms have been removed". But
that didn't mean there aren't "new" limits - only expanded bigger ones.
Hoisted by Micro-Speak and marketing.

I am really glad to see the work you did with TS applications. The phenomena
you mentioned had a lot to do in obscuring my view of what the limits really
were. Most 'huge' apps I have worked with were TS.

As for your observation on the TrueGrid, I also use it, and did occasionally
start to run into difficulty. We 'resolved' (work-around?) the problem by
reducing the number of Grid controls and heavily abusing the few remaining.
Quite often completely reconfiguring them on the fly. This had the expected
result - we made the app a little leaner and reduced the memory footprint,
but introduced delays when we switched context. (Damn trade-offs.)

Thanks again for sharing your results - I won't be so foolish the next time.
Well on "limits" anyway - there is still plenty of other areas and facts I
can stumble over. When it comes to being adamantly wrong - little discourges
me from doing my best. <g>

-ralph
Karl E. Peterson
2004-08-03 23:07:48 UTC
Permalink
Hi --
Post by EMS Solutions
I have finished my testing and it looks like Windows 2003 Server
and Windows XP offer much more room to move when GDI handles are
concerned compared to Windows 2000. I did manage to find hard
limits on repeated tests of each O/S.
That's really good news! It was way too little, before. Was there still a clamp per
process, in addition to per user?
Post by EMS Solutions
Note that I used the application KillNT.exe from
Very cool. I like it when something that simple can blow away an operating system on
command -- much to Microsoft's chagrin when I first posted it. <G>
Post by EMS Solutions
Thanks very much for all your assistance. You were a great help
and I think we've got a good result.
Glad to be a help.

Thanks... Karl
--
[Microsoft Basic: 1976-2001, RIP]
NickHK
2004-07-30 10:45:02 UTC
Permalink
In all this talk about GDI handles, is that the number represented by
"Handles" on the Task Manager, Performance tab ?

NickHK
Post by EMS Solutions
Thanks to everyone for the replies. Hard to know who is right or wrong,
all I can go with is my observations. Based on some more testing today, what
Robert stated seems to be consistent with my environment (Windows 2000
Professional Desktop, PIII 750, 512MB RAM).
Post by EMS Solutions
If I fire up a few of the GDI hungry apps, flick between the many screens
available within the application and watch the GDI handles grow and grow,
you can guarantee a serious GDI failure at around 10,000 GDI handles. Every
time! That's a pretty firm limit in my book.
Post by EMS Solutions
Tomorrow I hope to use the little app (provided in one of your links)which
will consume GDI handles until break point. I will test this on a Windows
2000 Terminal Server, then re-test with the same server loaded with Windows
2003 Server. I'll let you know the results. Basically I just want to be sure
the GDI limitation is noticeably higher on Windows 2003/XP.
Post by EMS Solutions
Just to frighten you all - our app which seems to tip the O/S over the
edge can consume as many as 6,000 GDI handles on it's own! Our development
team are telling me there is not a great deal else we can do with VB6 and
the amount of Grids and Forms needed in the specification. Ie, we need this
many handles to provide the functionally rich application and also give good
performance when switching between screens. We use a few 3rd party Grids,
Tree Views and List Bars, so perhaps there is nothing we can do... Let me
know if you think otherwise. I agree from a network Admin point of view that
perhaps the O/S is not to blame, but the application's hungry GDI usage.
Post by EMS Solutions
Cheers,
Chris Matthews
Network Manager
EMS Solutions
Karl E. Peterson
2004-07-30 22:33:03 UTC
Permalink
Post by NickHK
In all this talk about GDI handles, is that the number represented by
"Handles" on the Task Manager, Performance tab ?
I think it's the number in the "GDI Objects" column.
--
[Microsoft Basic: 1976-2001, RIP]
D***@home.com
2004-07-30 22:42:29 UTC
Permalink
Post by Karl E. Peterson
Post by NickHK
In all this talk about GDI handles, is that the number represented by
"Handles" on the Task Manager, Performance tab ?
I think it's the number in the "GDI Objects" column.
I don't have a clue...
Using Winders 98 and the Task Managers name is Helen Wait..
So if you have problems goto Helen Wait... hahaha

Have a good day...

Don
Loading...