--- a/WinWorkstation.st Wed May 04 21:33:11 2016 +0100
+++ b/WinWorkstation.st Wed May 04 22:12:41 2016 +0100
@@ -6485,6 +6485,54 @@
%}
!
+getGuiResources
+ "For resource debugging only. Returns an array containing
+ number of allocated / peak user / GDU objects.
+
+ NOTE: This method uses GetGuiResources() Windows API so it returns
+ values of Windows counters as opposite to WinWorkstation internal
+ counters (which are returned by #getHandleCounts family of methods)."
+
+ | counts |
+
+ counts := Array new: 4.
+%{
+/* Sigh, _PEAK constants seems not to be defined under MinGW / MinGW64.
+ * Define them here.
+ */
+#ifndef GR_GDIOBJECTS_PEAK
+# define GR_GDIOBJECTS_PEAK 2
+#endif
+#ifndef GR_USEROBJECTS_PEAK
+# define GR_USEROBJECTS_PEAK 4
+#endif
+ HANDLE proc = GetCurrentProcess();
+ __ArrayInstPtr(counts)->a_element[0] = __MKSMALLINT(GetGuiResources(proc, GR_GDIOBJECTS));
+ __ArrayInstPtr(counts)->a_element[1] = __MKSMALLINT(GetGuiResources(proc, GR_GDIOBJECTS_PEAK));
+ __ArrayInstPtr(counts)->a_element[2] = __MKSMALLINT(GetGuiResources(proc, GR_USEROBJECTS));
+ __ArrayInstPtr(counts)->a_element[3] = __MKSMALLINT(GetGuiResources(proc, GR_USEROBJECTS_PEAK));
+%}.
+ ^counts
+
+!
+
+printGuiResourceCounts
+ "Show number of allocated user / GDI objects.
+
+ NOTE: This method uses GetGuiResources() Windows API so it prints
+ values of Windows counters as opposite to WinWorkstation internal
+ counters (which are returned by #printHandleCounts)."
+
+ | counts |
+
+ counts := self getGuiResources.
+
+ 'GetGuiResources(): # User Objects = ' errorPrint. counts first errorPrintCR.
+ ' Peak User Objects = ' errorPrint. counts second errorPrintCR.
+ ' # GDI Objects = ' errorPrint. counts third errorPrintCR.
+ ' Peak GDI Objects = ' errorPrint. counts fourth errorPrintCR.
+!
+
printHandleCounts
"show prim values"