w0uter Posted July 16, 2005 Share Posted July 16, 2005 point 1: you cant use @AUTOITPID as a dll point 2: the code changed #93192 My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
therks Posted July 17, 2005 Share Posted July 17, 2005 Hmm, I just realized this function requires the psapi.dll. That's the one that doesn't come with WinNT4 right? So you might want to mention that in the function or something. Maybe do a fileexist for psapi.dll. If @OSVersion = 'WIN_NT4' Then FileInstall('psapi.dll', @SystemDir & '\psapi.dll') How's that look for making sure the psapi is on the system? My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
buzz44 Posted July 18, 2005 Share Posted July 18, 2005 Try looking in the folder where you installed AutoIt :">. qq Link to comment Share on other sites More sharing options...
therks Posted July 18, 2005 Share Posted July 18, 2005 No, no, I know where it is. I'm just saying that as far as redistributing a script that uses this function, in the case that it ends up on a WinNT4 system, how does that little snippet look for making sure that psapi.dll ends up being where it should? My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
buzz44 Posted July 18, 2005 Share Posted July 18, 2005 My bad Saunders, I assumed the the computer would have AutoIt installed :">. Snippet looks fine. qq Link to comment Share on other sites More sharing options...
erifash Posted July 18, 2005 Share Posted July 18, 2005 (edited) @w0uter: Shouldn't this code do the exact same thing that yours does? Func _ReduceMemory($iPID = -1) Local $aHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $iPID), $aReturn = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $aHandle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $aHandle[0]) Return $aReturn[0] EndFunc ;==>_ReduceMemory() Plus it's slightly faster than your function, about 0.3 ms (on my comp) averaged 50 times for each function. Here is the time trial: expandcollapse popupFunc _ReduceMemory1($iPID = -1) Local $aHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $iPID), $aReturn = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $aHandle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $aHandle[0]) Return $aReturn[0] EndFunc ;==>_ReduceMemory() Func _ReduceMemory2($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() $end = 0 For $i = 1 to 50 $pid = Run("notepad.exe") ProcessWait($pid) $start = TimerInit() _ReduceMemory1($pid) $end = $end + TimerDiff($start) ProcessClose($pid) Sleep(250) Next $time1 = $end / 50 $end = 0 For $i = 1 to 50 $pid = Run("notepad.exe") ProcessWait($pid) $start = TimerInit() _ReduceMemory2($pid) $end = $end + TimerDiff($start) ProcessClose($pid) Sleep(250) Next $time2 = $end / 50 MsgBox(0, "Average Speed", "_ReduceMemory1() = " & $time1 & @CRLF & "_ReduceMemory2() = " & $time2) It's not a whole lot of speed improvement but I am always glad to help out! Edited July 18, 2005 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
w0uter Posted July 18, 2005 Share Posted July 18, 2005 _ReduceMemory1() = 1.45895879641148 _ReduceMemory2() = 1.39595427417348 also you func fails if it tries to operate on itself with the -1 pid. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
alexischeng Posted July 22, 2005 Share Posted July 22, 2005 _ReduceMemory1() = 1.45895879641148_ReduceMemory2() = 1.39595427417348also you func fails if it tries to operate on itself with the -1 pid.<{POST_SNAPBACK}>I modify this code but I can't see any memory usage reduced. Is there anything wrong?Func _ReduceMemory1($iPID = -1) Local $aHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $iPID), $aReturn = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $aHandle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $aHandle[0]) Return $aReturn[0]EndFunc ;==>_ReduceMemory()Func _ReduceMemory2($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()Local $newlist,$oldlistwhile 1$list = ProcessList()$newlist=$list[0][0]If $oldlist<>$newlist Then for $i = 1 to $list[0][0]$pid=$list[$i][1]_reducememory1($pid)_reducememory2($pid)next$oldlist=$newlistEndIfsleep (5000)WEnd Link to comment Share on other sites More sharing options...
w0uter Posted July 22, 2005 Share Posted July 22, 2005 maby you dont have the PSAPI.dll ? My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Chris86 Posted August 17, 2007 Share Posted August 17, 2007 Hello. Im using a HP Omnibook 6100 :S only got 128 ram. so if i open to many webpages or if more than 2 person pms on msn then the computer gets really slow :S Can any of u write whole the code and post it here? (i use Win XP) Link to comment Share on other sites More sharing options...
Fabry Posted August 17, 2007 Share Posted August 17, 2007 Try this Memory fusion A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center] Link to comment Share on other sites More sharing options...
magician13134 Posted May 28, 2008 Share Posted May 28, 2008 Awesome script! I'm definitely going to use this!! Great work, guys! Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
mblunk Posted July 29, 2008 Share Posted July 29, 2008 (edited) I'm trying to use this on all processes running on a computer... is there any better way to do it than this? Func _ReduceMemory() $list = ProcessList() For $i = 1 To $list[0][0] Local $ai_Handle = DllCall("kernel32.dll", "int", "OpenProcess", "int", 0x1f0fff, "int", False, "int", $list[$i][1]) Local $ai_Return = DllCall("psapi.dll", "int", "EmptyWorkingSet", "int", $ai_Handle[0]) DllCall("kernel32.dll", "int", "CloseHandle", "int", $ai_Handle[0]) Next EndFunc ;==>_ReduceMemory Edited July 29, 2008 by mblunk Link to comment Share on other sites More sharing options...
JRowe Posted July 30, 2008 Share Posted July 30, 2008 Wow, wait... so now AutoIt can make everything use less memory? [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 30, 2008 Moderators Share Posted July 30, 2008 Wow, wait... so now AutoIt can make everything use less memory?http://msdn.microsoft.com/en-us/library/ms682606(VS.85).aspx 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...
JRowe Posted July 30, 2008 Share Posted July 30, 2008 Thank you It's obviously a very new concept to me, and I appreciate the link. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
mblunk Posted July 31, 2008 Share Posted July 31, 2008 Yeah, I made a pretty expansive program that is based around EmptyWorkingSet. If it weren't for this thread, it wouldn't exist. Read more about it here: http://forums.facepunchstudios.com/showthread.php?t=544709 Link to comment Share on other sites More sharing options...
rajeshontheweb Posted April 7, 2009 Share Posted April 7, 2009 (edited) when i first saw the memory reduction UDF earlier somewhere, i had started this simple udf to get the list of all processes and freeing up the memory - light duty - windows way - harmless. coz some memory optimisers force freeing of memory and at times, i get trouble of frozen processes for few moments, as the cache in RAM is cleared and firefox with many tabs, etc take longer time to respond after running the RAM optimiser. i am actully gonna work when i get free time to create a script to check memory level and when memory goes down , it will automatically trigger auto free if it is still low, then we will call for a third party ram freeing application :-) something like Memory fusion already in here Edited April 7, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
rajeshontheweb Posted May 17, 2009 Share Posted May 17, 2009 (edited) a bit late post, but just my minor mod for newbies who wanna use it Func _ReduceMemory($ProcID = 0) ; Original version : w_Outer ; modified by Rajesh V R to include process ID If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesnt exist - use current process instead. Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId') $ProcID = $ai_GetCurrentProcessId[0] EndIf Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ProcID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Return $ai_Return[0] EndFunc this will get your process id as input if u dont supply a input then it will automatically reduce current process's memory. i am thinking of checking if it is a pid or a string and supply string name as well, but i will see if i happened to need that mod i will post it here <edit> oops! small error in variable name... Edited May 17, 2009 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
ProgAndy Posted May 17, 2009 Share Posted May 17, 2009 it is better to use GetCurrentProcess for the own Process and not OpenProcess Func _ReduceMemory($ProcID = 0) ; Original version : w_Outer ; modified by Rajesh V R to include process ID ; modified by Prog@ndy to include process handle If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesnt exist - use current process instead. Local $ai_GetCurrentProcess = DllCall('kernel32.dll', 'ptr', 'GetCurrentProcess') Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_GetCurrentProcess[0]) Return $ai_Return[0] EndIf Local $ai_Handle = DllCall("kernel32.dll", 'ptr', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ProcID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'ptr', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'ptr', $ai_Handle[0]) Return $ai_Return[0] EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes 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