AutoHotkey Community

It is currently May 26th, 2012, 5:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9  Next
Author Message
 Post subject:
PostPosted: February 24th, 2009, 8:12 pm 
Online
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
I believe that if you use this after each joyConfigChanged(), it will decrease memory usage, not sure :?:

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 1:14 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 3:33 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 4:21 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 7:40 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 9:35 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 9:54 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 6:20 pm 
Hello

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


Top
  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 6:39 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 9:01 pm 
Hello

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


Top
  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 9:08 pm 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Sure!

http://www.autohotkey.com/misc/AutoHotk ... 8-new4.exe


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2009, 10:18 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 26th, 2009, 12:58 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 26th, 2009, 1:27 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 26th, 2009, 1:42 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 129 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group