AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Beta version pre-v1.0.48: Up to 3x faster performance
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Announcements
View previous topic :: View next topic  
Author Message
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Tue Feb 24, 2009 7:12 pm    Post subject: Reply with quote

I believe that if you use this after each joyConfigChanged(), it will decrease memory usage, not sure Question
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Feb 25, 2009 12:14 am    Post subject: Reply with quote

Intriguing idea! I modified the test script accordingly (with displaying the driver and the current time, so un/plugging the joystick is seen, and a crash is apparent). The memory usage now jumps up and down. It still increases, albeit much more slowly. After 10 minutes it increased from 640KB to only 1MB, instead of the earlier 200MB. Since the timer runs 100 times slower in the real script, it might not crash in a day or two with this modification. Still, eliminating the memory leak would be nicer.
Code:
CoordMode ToolTip, Screen
h := DllCall("OpenProcess", UInt,0x1F0FFF, Int,0, Int,DllCall("GetCurrentProcessId"))
SetTimer MonitorJoysticks,1

MonitorJoysticks:
   dllcall("winmm.dll\joyConfigChanged", UInt,0) ; Force re-registering joysticks
   DllCall("SetProcessWorkingSetSize", UInt,h, Int,-1, Int,-1)
   tooltip % GetKeyState("JoyName") ": " A_Hour ":" A_Min ":" A_Sec, 0,0
Return

!z::
   DllCall("CloseHandle", Int,h)
ExitApp
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Wed Feb 25, 2009 2:33 am    Post subject: Reply with quote

Laszlo, if you get a chance please try tonne's idea of VMMap that I mentioned in my previous post. VMMap will hopefully give a more specific location for the where the extra memory is being allocated.
Back to top
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Feb 25, 2009 3:21 am    Post subject: Reply with quote

Unfortunatelly, the script in my previous post with fincs' idea (DllCall("SetProcessWorkingSetSize"... ) does not work. After about 50 minutes the PC crashes. I tried it three times, with the same results.

VMmap killed TaskManager, and did not provide any info I understand. I need the help of a Windows expert...
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Feb 25, 2009 6:40 am    Post subject: Reply with quote

This exhibits the same behaviour:
Code:
VarSetCapacity(jc, 404, 0)
SetTimer MonitorJoysticks

MonitorJoysticks:
    DllCall("winmm.dll\joyConfigChanged", UInt, 0)
    DllCall("winmm.dll\joyGetDevCapsA", UInt, 0, UInt, &jc, UInt, 404)
Return

!z::ExitApp
A full equivalent to JoyName:=GetKeyState("JoyName") would be:
Code:
VarSetCapacity(jc, 404, 0), VarSetCapacity(JoyName, 0x20)
if (0 = DllCall("winmm.dll\joyGetDevCapsA", UInt, 0, UInt, &jc, UInt, 404))
    DllCall("lstrcpyn", Str, JoyName, UInt, &jc+4, UInt, 0x20)

Laszlo wrote:
Fixing this issue was important, because joystick using applications need to know if a joystick gets unplugged.
Quote:
Source: MSDN: joyGetNumDevs
Use the joyGetPos function to determine whether a given joystick is physically attached to the system. If the specified joystick is not connected, joyGetPos returns a JOYERR_UNPLUGGED error value.
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Feb 25, 2009 8:35 am    Post subject: Reply with quote

Thanks, Lexikos! I tried joyGetDevCapsA (as you saw in my Ask for Help post), and JoyGetPos, but after a joystick is unplugged several minutes can pass until the result becomes 167 (JOYERR_UNPLUGGED). I gave up waiting, thinking it did not detect unplugging. Do you know a way to ask Windows to rescan the joysticks? Maybe once or twice a minute. 5 minutes delay looks incredibly long.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Feb 25, 2009 8:54 am    Post subject: Reply with quote

Actually, I had not seen your Ask for Help post. I merely looked into the AutoHotkey source and found that GetKeyState("JoyName") uses joyGetDevCaps. I tested joyGetPos with my wireless Xbox 360 controller, and the return value immediately reflects disconnection/reconnection. joyGetPos is the recommended method according to MSDN as quoted in my previous post.
Back to top
View user's profile Send private message Visit poster's website
Mhz
Guest





PostPosted: Wed Feb 25, 2009 5:20 pm    Post subject: Reply with quote

Hello

I try to UnZip the compiler file and i end up with a big bin file. What am i doing wrong ?
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Feb 25, 2009 5:39 pm    Post subject: Reply with quote

You need to drop it in the following folder
?:\Program Files\AutoHotkey\Compiler

.. and you need to recompile your existing compiled scripts to reflect the upgrade.
Back to top
View user's profile Send private message Send e-mail
Mhz
Guest





PostPosted: Wed Feb 25, 2009 8:01 pm    Post subject: Reply with quote

Hello

AAAh Ok i don't have the compiler. Can you just give us the exe ?
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Feb 25, 2009 8:08 pm    Post subject: Reply with quote

Sure!

http://www.autohotkey.com/misc/AutoHotkey-Pre-1.0.48-new4.exe
Back to top
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Wed Feb 25, 2009 9:18 pm    Post subject: Reply with quote

The following script crashes after a few minutes, with a little, slow, but constant increase of memory footprint:
Code:
CoordMode ToolTip, Screen
VarSetCapacity(JOYINFO,16)
DllCall("winmm\timeBeginPeriod", UInt,1)
DllCall("winmm\timeSetEvent", UInt,10, UInt,0, UInt,RegisterCallback("Timer"), UInt,0, UInt,1)
SetTimer Sometimes

Timer(uTimerID, uMsg, dwUserP, dw1P, dw2P) {
   Global
   tooltip % Joy1 "." Joy2 "." A_TickCount, 0,0,20
}
!z::ExitApp
Sometimes:
   Loop 16
      Joy%A_Index% := DllCall("winmm.dll\joyGetPos", Uint,A_Index-1, Uint,&JOYINFO)=0
Return
If I don't use dynamaic variables the script looks more stable.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Wed Feb 25, 2009 11:58 pm    Post subject: Reply with quote

I'm still hampered by the lack of a joystick (all I have is an ancient one that needs a joystick port I no longer have). But I ran it in the debugger for about 15 minutes and nothing unusal happened. The memory increased very slowly, perhaps 4 KB every 5 minutes.

If you ever get bad behavior with routines other than joystick, please let me know. In the meantime, maybe others can test your script above in case it's an issue with one particular kind of joystick or driver.
Back to top
View user's profile Send private message Send e-mail
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Thu Feb 26, 2009 12:27 am    Post subject: Reply with quote

Chris wrote:
...nothing unusal happened. The memory increased very slowly, perhaps 4 KB every 5 minutes.
Since the script does not create or enlarge variables after the first second, is not even a slow memory increase unusual? If I remove the joystick calls, the memory footprint remains constant.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Thu Feb 26, 2009 12:42 am    Post subject: Reply with quote

Yes, seeing memory usage slowly increase would be cause for concern. However, the memory seems to be increasing in the shared working set, which the program doesn't do anything with, and maybe has no direct control over.

Since the private memory ("VM Size" in Task Manager) isn't increasing, perhaps that proves that the program is not allocating any memory from the stack or heap. This is supported by those unreached breakpoints I did for your prior script, though I haven't done it for this one.

VMMap seemed quite promising because it revealed exactly what DLLs or modules are using memory. But on my system, the memory increase was so little and took so long that VMMap probably wouldn't give a definitive answer.

If no one else with a joystick is able to get useful results from VMMap, I can try running a script overnight again to see what it shows.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Announcements All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 8 of 9

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group