Many of you docklet developers may have wondered why and how you got millions of page faults in your Task Manager for YzDock, ObjectDock and AveDesk, especially if you run them for a longer period of time, e.g. sending your PC to hibernate instead of rebooting it each morning. (+150 /sec.)
Was it a resource leak in your Docklet? Did you allocate tons of strings in a wasteful manner so that the VC++ heap manager got fragmented?
Neither. It's a flaw in the SDK each three are suffering from the first beginning.
See the following OD-SDK code excerpt:
BOOL DockletIsVisible(HWND hwndDocklet)
{
typedef BOOL(__stdcall *DUMMY_TYPEDEF)(HWND hwndDocklet);
DUMMY_TYPEDEF HostDockletIsVisible = (DUMMY_TYPEDEF) GetProcAddress(GetModuleHandle(NULL), "DockletIsVisible");
if(!HostDockletIsVisible)
return FALSE;
return HostDockletIsVisible(hwndDocklet);
}
Whenever you call DockletIsVisible() in your Docklet, this code loads the discardable portion of ObjectDock.exe, maps the DockletIsVisible function pointer into a temporary variable and calls the function. Each of these calls will produce a page fault, because the Win32 Loader will assume that the procedure address info is only needed once and - ignoring how many RAM you have - silently page out this portion of the exe into the pagefile.sys in your boot partition.
Since programmers are a lazy species, this applies unfortunately to the way your exported functions are called, too. Whenever any of your exports need to get called, the preload / discardable marked export section gets read from the hard disk again and again. Imagine, you have a WM_TIMER message to handle - OnProcessMessage() gets shifted from the pagefile to the RAM each time the message arrives. On my 1GHz PC, my HD LED blinks every second if I have only the CPU-Monitor Docklet on either YZ, OD or AD.
Finally, it is a stupid waste.
Exported functions can't go away between two calls since they are cemented at compile time - dumbly looking them up each time consumes unnecessary CPU time.
Ideas on how to remedy:
1. Create your own window for handling timer messages in your timer based docklets.
2. Don't export empty routine stubs.
3. Insist on the authors to fix this.
4. Research the possibility of how to force your export table to remain in RAM (YZ)
5. In the case of OD, I would recommend the attached header file for calling the Docklet API. It also keeps the window handle.
Have a nice undisturbed coding experience,
herd
Aqua-Soft Forums