 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
kidmar
Joined: 04 Oct 2007 Posts: 30
|
Posted: Mon Nov 05, 2007 11:09 am Post subject: UrlDownloadToFile memory anomaly |
|
|
I have some problem with UrlDownloadToFile.
It works good but it occupies 2.5MB of ram after it finishes.
I have a script that calls a function that uses UrlDownloadToFile.
Before the UrlDownloadToFile line the script uses about 3.5MB of ram (taskmanager). Right after it finishes it uses about 6MB.
Does someone know why?
Is there a function to call after UrlDownloadToFile to free the memory it uses? maybe something like a garbage collector.
Does it happen to me only?
Maybe it's just a bug in UrlDownloadToFile..
Thank you. |
|
| Back to top |
|
 |
kidmar
Joined: 04 Oct 2007 Posts: 30
|
Posted: Mon Nov 05, 2007 11:30 am Post subject: |
|
|
| I tried monitoring the script with Process Explorer and the result is about the same (1.5MB instead of 2.5 if i look at "WS Private" value) |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2739 Location: Australia, Qld
|
Posted: Tue Nov 06, 2007 3:31 am Post subject: |
|
|
UrlDownloadToFile causes AutoHotkey to load a number of libraries. I'd say this accounts for the increased memory usage.
Before UrlDownloadToFile: | Code: | Image Name PID Modules
========================= ======== ============================================
AutoHotkey.exe 4080 ntdll.dll, kernel32.dll, ADVAPI32.dll,
RPCRT4.dll, COMCTL32.dll, msvcrt.dll,
GDI32.dll, USER32.dll, SHLWAPI.dll,
COMDLG32.dll, SHELL32.dll, ole32.dll,
OLEAUT32.dll, VERSION.dll, WINMM.dll,
OLEACC.dll, WSOCK32.dll, WS2_32.dll,
NSI.dll, ShimEng.dll, apphelp.dll,
AcLayers.DLL, USERENV.dll, Secur32.dll,
WINSPOOL.DRV, MPR.dll, IMM32.DLL,
MSCTF.dll, LPK.DLL, USP10.dll, uxtheme.dll | After UrlDownloadToFile: | Code: | Image Name PID Modules
========================= ======== ============================================
AutoHotkey.exe 4080 ntdll.dll, kernel32.dll, ADVAPI32.dll,
RPCRT4.dll, COMCTL32.dll, msvcrt.dll,
GDI32.dll, USER32.dll, SHLWAPI.dll,
COMDLG32.dll, SHELL32.dll, ole32.dll,
OLEAUT32.dll, VERSION.dll, WINMM.dll,
OLEACC.dll, WSOCK32.dll, WS2_32.dll,
NSI.dll, ShimEng.dll, apphelp.dll,
AcLayers.DLL, USERENV.dll, Secur32.dll,
WINSPOOL.DRV, MPR.dll, IMM32.DLL,
MSCTF.dll, LPK.DLL, USP10.dll, uxtheme.dll,
wininet.dll, Normaliz.dll, iertutil.dll,
RASAPI32.dll, rasman.dll, NETAPI32.dll,
PSAPI.DLL, TAPI32.dll, rtutils.dll,
sensapi.dll, credssp.dll, CRYPT32.dll,
MSASN1.dll, schannel.dll, NLAapi.dll,
IPHLPAPI.DLL, dhcpcsvc.DLL, DNSAPI.dll,
WINNSI.DLL, dhcpcsvc6.DLL, rasadhlp.dll,
urlmon.dll, mswsock.dll, wshtcpip.dll,
wship6.dll, winrnr.dll, WLDAP32.dll,
napinsp.dll, pnrpnsp.dll |
How I got these results: | Code: | Process, Exist
pid := ErrorLevel
Run %comspec% /k tasklist /FI "PID eq %pid%" /M
Sleep, 2000 ; give it some time, but don't wait for it to close
UrlDownloadToFile, http://www.autohotkey.com/download/CurrentVersion.txt, Z:\AutoHotkey Latest Version.txt
RunWait %comspec% /k tasklist /FI "PID eq %pid%" /M |
UrlDownloadToFile only explicitly loads wininet, which it frees when the download is complete. I guess something loaded by wininet prevents it from being freed. Explicitly freeing wininet (using GetModuleHandle and FreeLibrary) frees a small amount of memory (about 70K), but leaves the many other libraries (presumably loaded by wininet) in memory.
Edit: Freeing wininet using GetModuleHandle and FreeLibrary also frees Normaliz.dll, iertutil.dll, sensapi.dll, and urlmon.dll. |
|
| Back to top |
|
 |
kidmar
Joined: 04 Oct 2007 Posts: 30
|
Posted: Tue Nov 06, 2007 8:57 am Post subject: |
|
|
Thank you very much for your accurate reply!
I'm sorry but I can just understand a part of what you said..
For what I understand, UrldDownloadToFile opens wininet; probabily winnet opens some libraries and leaves them in memory after it closes.
My question is: Will these libraries stay in memory even if I close my autohotkey script? If not I can run the download in a separate script. I hope that when the original process terminates every dll opened by it will close.
I tried and looks so. Could you please confirm this? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2739 Location: Australia, Qld
|
Posted: Tue Nov 06, 2007 11:29 am Post subject: |
|
|
| kidmar wrote: | | My question is: Will these libraries stay in memory even if I close my autohotkey script? | Exiting a program frees all libraries it is using. It also frees any memory allocated to the program. (In this case "program" refers to AutoHotkey, making no distinction between the script engine and the script.)
| Quote: | | If not I can run the download in a separate script. I hope that when the original process terminates every dll opened by it will close. | I was actually going to recommend that, but I got side-tracked trying to figure out why wininet wasn't being unloaded.  |
|
| Back to top |
|
 |
kidmar
Joined: 04 Oct 2007 Posts: 30
|
Posted: Tue Nov 06, 2007 4:40 pm Post subject: |
|
|
ok thank you very much.
with the separate script everything is ok!
bye bye |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|