NU2 Posted November 18, 2010 Share Posted November 18, 2010 I have a simple .au3 script that is as follows: DllCall("<dll path>.dll", "int", "SetBool", "Int", 12, "Int", 1) It works great for the first 50k iterations. Return is between .4 - .9 seconds. Then the return starts taking around 2.6 - 3.9 seconds. I can't figure out what is causing the issue. I have tried restarting the PC hoping that something in memory gets reset but to no avail. The dll is compiled in C. I have also tried to use the DLLOpen and DLLClose and use the $dll in the DLLCall instead of just the DLLCall with the dll path. Is there some sort of log or something that is maxing out that I'm missing? I apologize if I have left out any information. Please let me know what additional information you need to help me debug. Like my user name implies, I'm new to this. Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 18, 2010 Share Posted November 18, 2010 I don't think anything in AutoIt would cause that behavior. More likely related to the DLL itself. Do you see a memory leak while it's running on Task Manager Processes tab? Can you call the DLL from something else, like VB? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NU2 Posted November 18, 2010 Author Share Posted November 18, 2010 I don't think anything in AutoIt would cause that behavior. More likely related to the DLL itself.Do you see a memory leak while it's running on Task Manager Processes tab?Can you call the DLL from something else, like VB?I haven't really seen a memory leak. I've been trying to figure out how to write a vbscript or something along those lines to call my dll function but I'm still digging. Link to comment Share on other sites More sharing options...
NU2 Posted November 19, 2010 Author Share Posted November 19, 2010 Just tested the dll call with another tool... The issue is definitely something with AutoIT. The second tool I am using the function is returning instantly. Any ideas would be appreciated. I will continue to dig. Thanks Link to comment Share on other sites More sharing options...
JohnOne Posted November 19, 2010 Share Posted November 19, 2010 Post working example code that causes the problem. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 19, 2010 Share Posted November 19, 2010 You should instead use DllOpen and call DllCall with the handle. This should produce an immediate improvement. Link to comment Share on other sites More sharing options...
NU2 Posted November 19, 2010 Author Share Posted November 19, 2010 I have also tried to use the DLLOpen and DLLClose and use the $dll in the DLLCall instead of just the DLLCall with the dll path.Post working example code that causes the problem.The problem is in the response time of my application. This dll call just sets a buttons on off state. Can't really show the code but this is what I have tried for dll call.I have tried both methods.#1DllCall("C:\Mydll\Mydll.dll", "Int", "SetBool", "Int", 16, "Int", 1)#2$dll = DllOpen("C:\Mydll\Mydll.dll")DllCall($dll, "Int", "SetBool", "Int", 16, "Int", 1) DllClose($dll)Both are now SLOW. Same function call performed in a 3rd party tool comes back immediately.Like I said, I had a loop of 50,000 DllCall() that work in .4 - .9 second range then it just started returning about 3.4 seconds. After restart and even after installing AutoIT on a second PC and performing the same test after 50k iterations, same out come. You should instead use DllOpen and call DllCall with the handle. This should produce an immediate improvement. Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 19, 2010 Share Posted November 19, 2010 You only open it once at the top of your script. Then you close the dll at the end when you are about to exit. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 19, 2010 Share Posted November 19, 2010 Like Richard said, if you are repeating the Open/Close cycle every time, you missed the point. And when you tested it with "another tool" did you repeat it 50K times? Because you said your AutoIt script didn't become slow until some iterations had passed. I seem to remember reading something on another topic about Windows "caching" closed handles for about 10 seconds to make sure new handles don't overlap invalid closed ones to quickly, or something like that. But the only way to hit that limit was fast open/close cycles in a tight loop. And that was a Windows issue, not AutoIt's. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
NU2 Posted November 22, 2010 Author Share Posted November 22, 2010 Like Richard said, if you are repeating the Open/Close cycle every time, you missed the point.And when you tested it with "another tool" did you repeat it 50K times? Because you said your AutoIt script didn't become slow until some iterations had passed.I seem to remember reading something on another topic about Windows "caching" closed handles for about 10 seconds to make sure new handles don't overlap invalid closed ones to quickly, or something like that. But the only way to hit that limit was fast open/close cycles in a tight loop. And that was a Windows issue, not AutoIt's.AH!! So I shouldn't be opening and closing the dll every call? I thought inside the DLLCall however, an open of the ddl was performed, then the function and then a close??The other tool is still running. It's currently at 273,196 iterations and not a single slow down. I will have to do a search to see if I can find the Windows "caching" issue. The AutoIT DLLCall is exactly what I need to I'm hoping I can get this straightened out. I'll be sure to post a resolution if I find one and if any one has any additional thoughts please share.Thanks again. Link to comment Share on other sites More sharing options...
water Posted November 22, 2010 Share Posted November 22, 2010 (edited) AH!! So I shouldn't be opening and closing the dll every call?Right! Open the DLL, call it in a loop and close the DLL when you exit your script: $dll = DllOpen("C:\Mydll\Mydll.dll") ; Open the DLL when the script starts While 1 ; Here starts your loop If $condition = True then ExitLoop ; Check condition. If true exit the loop DllCall($dll, "Int", "SetBool", "Int", 16, "Int", 1) Wend DllClose($dll) ; Close the DLL before you exit the script Edited November 22, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
trancexx Posted November 22, 2010 Share Posted November 22, 2010 If your plan is to close it on exit then don't close it at all. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
James Posted November 22, 2010 Share Posted November 22, 2010 If your plan is to close it on exit then don't close it at all.Can you explain why this is so?Seriously willing to learn here Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
trancexx Posted November 22, 2010 Share Posted November 22, 2010 It's unnecessary. DllOpen loads the dll for AutoIt (your process) into its own (your) address space. After the process exit there is no such space anymore, meaning dll is unloaded whether you like it or not. Besides that, it's reasonable to expect that AutoIt would do it for you on exit (help file). ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
James Posted November 22, 2010 Share Posted November 22, 2010 It's unnecessary.DllOpen loads the dll for AutoIt (your process) into its own (your) address space. After the process exit there is no such space anymore, meaning dll is unloaded whether you like it or not. Besides that, it's reasonable to expect that AutoIt would do it for you on exit (help file).Sweet. Learn something new every day Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now