Champak Posted May 11, 2006 Share Posted May 11, 2006 Is there a way to wipe the memory/cache from the system throughout a script while a program stays open? Or will clearing the memory through the script out of whack with the variables? ...If that is the case, can you clear the memory relating to a specific program? Ex. Script start-- Loop begins---(loop a few times) Process 1--- Process 2--- Clear memory/cache Loop ends--- Process 3--- Script ends--- Did a search, couldn't come up with an end answer. Link to comment Share on other sites More sharing options...
BigDaddyO Posted May 11, 2006 Share Posted May 11, 2006 Check this Thread Here Link to comment Share on other sites More sharing options...
Paulie Posted May 11, 2006 Share Posted May 11, 2006 (edited) Is there a way to wipe the memory/cache from the system throughout a script while a program stays open? Or will clearing the memory through the script out of whack with the variables? ...If that is the case, can you clear the memory relating to a specific program? Ex. Script start-- Loop begins---(loop a few times) Process 1--- Process 2--- Clear memory/cache Loop ends--- Process 3--- Script ends--- Did a search, couldn't come up with an end answer. Are you looking for "DirRemove()" Edited May 11, 2006 by Paulie Link to comment Share on other sites More sharing options...
Champak Posted May 12, 2006 Author Share Posted May 12, 2006 Mike, I get an error when I try that code. No Paulie, that wouldn't help me. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 12, 2006 Moderators Share Posted May 12, 2006 Mike, I get an error when I try that code. No Paulie, that wouldn't help me.Did you use it exactly like that, or did you by any chance put any "error" handling in it? Do you have the psapi.dll on the computer your trying to use it on? If you do, is the psapi.dll located at the script dir or in the @systemdir? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 I used it as is...or maybe I'm not using it correctly. I copied it to a page by itself and called it. I then checked how much memory was reduced, and the exact same amount was there as before I called it. I have that dll in the program folder of autoit, in the system dir, and a couple other folders. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 I used it as is...or maybe I'm not using it correctly. I copied it to a page by itself and called it. I then checked how much memory was reduced, and the exact same amount was there as before I called it.I have that dll in the program folder of autoit, in the system dir, and a couple other folders.Well what was the error? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 Per your PM saying there was no error, then obviously your not calling it right. Do it like this:;_ReduceMemory() Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory() While 1 Sleep(100) WEndOnce Then do it like this:_ReduceMemory() Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory() While 1 Sleep(100) WEndit dropped 2700 k when I tried it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 (edited) OK, I don't know what I'm doing wrong, or if I'm looking for the wrong thing. I'm calling it by double clicking the script, and I also put it in a gui and called it from a button. Then I use the memory get stats to see what percentage is in use, and it hasn't been reduced. Do I have the right idea of how this works? Also, the only time I got an error was with the false statement, so I put a quotation around false and that error didn't come up again. That error was an unknown function. Edited May 13, 2006 by Champak Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 OK, I don't know what I'm doing wrong, or if I'm looking for the wrong thing. I'm calling it by double clicking the script, and I also put it in a gui and called it from a button. Then I use the memory get stats to see what percentage is in use, and it hasn't been reduced. Do I have the right idea of how this works? Also, the only time I got an error was with the false statement, so I put a quotation around false and that error didn't come up again. That error was an unknown function.You got an error with False because your not using Beta... Replace False with 0, example (with beta of course):$v = 1 If $v = True Then MsgBox(0, 'True Proof:', $v & ' = True') $v = 0 If $v = False Then MsgBox(0, 'False Proof:', $v & ' = False') Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 Is there a particular file to grab from the beta download in order to get this function, or do I need the whole thing? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 Is there a particular file to grab from the beta download in order to get this function, or do I need the whole thing?You just need to download Beta, and run in SciTe with Alt+F5. Most functions we use are with Beta so you really should have it anyway. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 I got the beta and am activating it through "beta run", and still nothing. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 I got the beta and am activating it through "beta run", and still nothing.Why don't you show the script and how your executing it, there's nothing wrong with the code, it's your implementation I would be willing to bet. We could chase our tails for several days or solve the problem right now... Also what OS are you using it on? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 (edited) The script I was calling it with a button, I deleted that already, but the other way was simply copying this exactly what's there with no changes or additions, saving it and calling it from beta run-open. Edited May 13, 2006 by Champak Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 13, 2006 Moderators Share Posted May 13, 2006 The script I was calling it with a button, I deleted that already, but the other way was simply copying this exactly what's there with no changes or additions, saving it and calling it from beta run-open.As I said, show how your using it, and what OS. Are you sure your computer has the psapi.dll? This script does work. It reduces the "Memory Usage" total, use Task Manager to see it, run it in a fresh script (Test.au3) or something without the function call, then run it with the function call and you will see the difference. I don't know or understand what other implimentation your trying to use it for other than reducing the amount of memory usage it retains, but without a reproduction script, all we keep doing is making this thread larger. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Sardith Posted May 13, 2006 Share Posted May 13, 2006 It works for me also. Regular Autoit test ;_ReduceMemory Memory usage is: 3,964k After with it _ReduceMemory Memory usage is: 652k So thats a total of 3312k Free'd up. [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
Champak Posted May 13, 2006 Author Share Posted May 13, 2006 1/ Im using XP 2/ I have 5 psapi.dlls. 1 on the windows system32 folder, 1 in the beta folder 1 in the release folder, and with a few other apps. 3/ I put everything to a new file by itself as you said 4/ I'm calling it through the scite program with Alt F5. 5/ When I run it like: $i_PID = -1 If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] I get >"C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Documents and Settings\Money\Desktop\Gui test\Test.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams >Running AU3Check params: from:C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\SciTE\au3check\ C:\Documents and Settings\Money\Desktop\Gui test\Test.au3(11,24) : ERROR: 'Return' not allowed from global scope. Return $ai_Return[0] ~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Money\Desktop\Gui test\Test.au3 - 1 error(s), 0 warning(s) !>AU3Check ended.rc:2 >Running:(3.1.1.0):C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\autoit3.exe "C:\Documents and Settings\Money\Desktop\Gui test\Test.au3" C:\Documents and Settings\Money\Desktop\Gui test\Test.au3 (4) : ==> Unknown function name.: Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', ^ ERROR ->AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 3.725 When I run it the original way like: Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory() I get >"C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Documents and Settings\Money\Desktop\Gui test\clearmem.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams >Running AU3Check params: from:C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\SciTE\au3check\ +>AU3Check ended.rc:0 >Running:(3.1.1.0):C:\Additions\Misc\AutoIt v3.1.1\AutoIt3\autoit3.exe "C:\Documents and Settings\Money\Desktop\Gui test\clearmem.au3" C:\Documents and Settings\Money\Desktop\Gui test\clearmem.au3 (4) : ==> Unknown function name.: Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', ^ ERROR ->AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 0.764 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