Update: MSDN tells that the multimedia timer is obsolete. However, with the recommended replacement (CreateTimerQueueTimer) the memory footprint still grows and the script crashes even faster. It is in Vista-32 SP1, AHK Version 1.0.48.00. (Reducing the Timer function to a single i++ makes no difference.)
In my old laptop (XP SP3, AHK 1.0.47.05) the memory also steadily but very slowly increases (from 2504KB to over 4MB). The script did not crash overnight.
Contrary to my earlier note, a similar script (below) crashed (in Vista) even with the standard AHK timer. The memory shown by the Task Manager grew (2504KB --> ~2812KB), when the script slowed down (the tooltip update almost halted); some furious disk activity occured; and the script crashed in a minute.
The second time I ran the script it recovered from this slow down: it sped up again and the memory increase stopped. Of course, this slowdown renders the script useless, but this recovery is remarkable.
After a crash, the next time the script remains alive noticeably longer. Maybe Windows made room for some resources, and it takes longer to exhaust it.
Code:
CoordMode ToolTip, Screen
VarSetCapacity(JOYINFO,16,0)
DllCall("LoadLibrary", Str,"winmm.dll")
joyGetPos := DllCall("GetProcAddress", UInt,DllCall("GetModuleHandle",Str,"winmm"), Str,"joyGetPos")
SetTimer Sometimes, 33
SetTimer Ipp, 1
!z::ExitApp
Ipp:
iTimer++
Return
Sometimes:
JoyTemp =
Loop 16
JoyTemp .= DllCall(joyGetPos, Uint,A_Index-1, Uint,&JOYINFO) = 0
tooltip (%iTimer%/%A_Now%) %JoyTemp%, 0,0,20
Return