April 9th, 2024

If I enumerate all the processes and add up all the Get­Gui­Resources, why doesn’t it match the GR_GLOBAL value?

A customer was calling Get­Gui­Resources for each process and adding up the results and comparing that with just calling Get­Gui­Resources once with GR_GLOBAL. They found that the values didn’t match. What’s going on?

If you are doing this with the *_PEAK values, then it’s to be expected that adding the individual peaks will not match the global peak. After all, it’s almost certainly not the case that all of the processes reached their peak at the same time. Adding up the individual peaks will overshoot the global peak.

Time Objects
Process 1 Process 2 Global
t = 1 100 10 110
t = 2 50 50 100
Peak 100 50 110

On the other hand, if you add up the instantaneous counts, you will probably come up with a total less than the global value. That’s because there are some objects which are considered owned by the system itself and not any specific process. Examples include objects on the clipboard, stock objects, and certain types of bitmaps. Those system-owned objects count toward the global value but are not charged to any process.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.