Hammerfist Posted June 1, 2009 Share Posted June 1, 2009 (edited) <<<< _ReduceMemory GUI >>>>UDF so called '_ReduceMemory UDF' can optimize any process at the computer.So I wrote a small program that can reduce a RAM usage of any process excluding system processes. There are small stats:NOKIA PC Suite v7 (PCSuite.exe): 31890kb -->> 1089kbExplorer.exe: 19800kb -->> 2170kbHere are the source:expandcollapse popup#Region #AutoIt3Wrapper_outfile=Reducer.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=RAM Usage Reducer #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #EndRegion Global Const $GUI_EVENT_CLOSE = -3 Global Const $GUI_FOCUS = 256 Global Const $LVM_FIRST = 0x1000 Global Const $LVHT_ONITEMICON = 0x00000002 Global Const $LVHT_ONITEMLABEL = 0x00000004 Global Const $LVHT_ONITEMSTATEICON = 0x00000008 Global Const $LVHT_ONITEM = BitOR($LVHT_ONITEMICON, $LVHT_ONITEMLABEL, $LVHT_ONITEMSTATEICON) Global Const $LVN_FIRST = -100 Global Const $WS_MINIMIZEBOX = 0x00020000 Global Const $WS_SYSMENU = 0x00080000 Global Const $WS_CAPTION = 0x00C00000 Global Const $WS_POPUP = 0x80000000 Global Const $GUI_SS_DEFAULT_GUI = BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) Global $data[999], $pctrl[999] _Main() Func _ProcGet() $P_list = ProcessList() For $i = 1 to $P_List[0][0] $v1 = ProcessGetStats($p_list[$i][1], 0) If IsArray($v1) then $data[$i] = $p_list[$i][0] & "|" & $p_list[$i][1] & "|" & $v1[0]/1024 & " кб" Else $data[$i] = $p_list[$i][0] & "|" & $p_list[$i][1] & "|" & "<system>" EndIf Next $data[0] = $P_List[0][0] For $i = 1 to $data[0] GUICtrlDelete($pctrl[$i]) Next For $i = 1 to $data[0] $pctrl[$i] = GUICtrlCreateListViewItem($data[$i], $ListView1) Next EndFunc Func _Main() Local $pctrl[999] $Form1 = GUICreate("_ReduceMemory GUI", 447, 438, 193, 125) $Group1 = GUICtrlCreateGroup("Let's start!", 8, 4, 429, 425) Global $ListView1 = GUICtrlCreateListView("Process name|PID|RAM|", 16, 24, 410, 358) GUICtrlSendMsg(-1, 0x101E, 0, 230) GUICtrlSendMsg(-1, 0x101E, 1, 50) GUICtrlSendMsg(-1, 0x101E, 2, 90) GUICtrlSendMsg(-1, 0x101E, 3, 1) $Button1 = GUICtrlCreateButton("Optimize selected process", 22, 392, 200, 25, 0) $Button2 = GUICtrlCreateButton("Refresh list", 228, 392, 200, 25, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetBkColor(0xffffff) GUISetState(@SW_SHOW) _ReduceMemory(@AutoItPID) _ProcGet() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $plist1 = GUICtrlRead($ListView1) $Pdata = GUICtrlRead($plist1) If $pdata <> "" and Not StringInStr($pdata, "<system>") then $Name = StringSplit($pdata, "|") $NameP = $Name[2] _ReduceMemory($namep) _ProcGet() EndIf GUICtrlSetState($plist1, $GUI_FOCUS) Case $Button2 $plist1 = GUICtrlRead($ListView1) _ProcGet() GUICtrlSetState($plist1, $GUI_FOCUS) EndSwitch WEnd EndFunc Func _ReduceMemory($i_PID) 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 ;==>_ReduceMemoryEnjoy =)) Edited June 1, 2009 by Hammerfist My topics:<<<< Project ECO Helper >>>><<<< _ReduceMemory GUI >>>> Link to comment Share on other sites More sharing options...
trancexx Posted June 1, 2009 Share Posted June 1, 2009 (edited) Why would you want to reduce memory usage of explorer.exe for example? Do you think that's needed? Do you think developers of explorer.exe (or almost any other app) forgot about that? edit: Nice gui. Refreshingly white. Edited June 1, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
WideBoyDixon Posted June 1, 2009 Share Posted June 1, 2009 See here : http://msdn.microsoft.com/en-us/library/ms682606(VS.85).aspxNote that EmptyWorkingSet has been moved to kernel32.dll in Windows 7 and above.WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
stinson6016 Posted June 1, 2009 Share Posted June 1, 2009 I think MicroSoft doesn't care about reducing memory with their programs, I think that they try to use as much memory as they can with every program expecting you (the end user) to always have to newest computers running their software. Most updates they release do not work well on three to five year old computer. but that's just my thoughts. Gnatwork Networks Link to comment Share on other sites More sharing options...
rajeshontheweb Posted June 1, 2009 Share Posted June 1, 2009 its not just that they forgot to release the memory but for the end user, it is preferrable to release the memory SPECIALLY EMPTYWORKINGSET which does give a bit of ram on every usage. but nevertheless, microsoft programs do take their own part of ram as much as needed in few moments (of course, same applies to most programs) and btw, it is very helpful with most programs specially stuff where the memory release is not explicitly done. because as far as i have understood windows may not try to occupy the space of unreleased objects / etc unless the space is required by other process! 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...
trancexx Posted June 1, 2009 Share Posted June 1, 2009 See here : http://msdn.microsoft.com/en-us/library/ms682606(VS.85).aspxNote that EmptyWorkingSet has been moved to kernel32.dll in Windows 7 and above.WBDSee here.But that's not the answer to my question.Btw, if wraithdu actually answered my question in that thread things would be much clearer. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
James Posted June 1, 2009 Share Posted June 1, 2009 Add: Dim $ListView1 To remove the error about the listview. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
monoceres Posted June 1, 2009 Share Posted June 1, 2009 You should all know that this is not an optimizer but will in most cases make the programs run slower (however it will indeed temporarily free up ram). Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Hammerfist Posted June 2, 2009 Author Share Posted June 2, 2009 (edited) You should all know that this is not an optimizer but will in most cases make the programs run slower (however it will indeed temporarily free up ram).I dont know how do you want to use it but I use this 'optimizer' to optimize 'background' applications such as PCSuite. They all need a very few RAM amount to work correctly.Note that EmptyWorkingSet has been moved to kernel32.dll in Windows 7 and above.WBDAll my progs are for WinXP because I haven't so powerful machine to work on Win7 and even Vista. I have no reason to work with Vista or Win7 tech documentation. Sorry =( Edited June 2, 2009 by Hammerfist My topics:<<<< Project ECO Helper >>>><<<< _ReduceMemory GUI >>>> Link to comment Share on other sites More sharing options...
Hammerfist Posted June 2, 2009 Author Share Posted June 2, 2009 Why would you want to reduce memory usage of explorer.exe for example?Do you think that's needed? Do you think developers of explorer.exe (or almost any other app) forgot about that?1st: 'explorer.exe' is just an example.2nd: if you change the current page in the 'explorer tree' you can see that RAM usage of 'explorer.exe' process grows up to the same 30MB.3rd: even if developer of 'explorer' include that function as some cleanup function, it will only clean up non-released pages and they will soon be fill by 'fresh' data. My topics:<<<< Project ECO Helper >>>><<<< _ReduceMemory GUI >>>> Link to comment Share on other sites More sharing options...
trancexx Posted June 2, 2009 Share Posted June 2, 2009 1st: 'explorer.exe' is just an example.2nd: if you change the current page in the 'explorer tree' you can see that RAM usage of 'explorer.exe' process grows up to the same 30MB.3rd: even if developer of 'explorer' include that function as some cleanup function, it will only clean up non-released pages and they will soon be fill by 'fresh' data.That's why I said for example.I'm confident that RAM usage of that kind of processes is always as it should be. There are something called caching and that is done intentionally to improve performance, not to reduce it. Memory leak is always possible but extremely unlikely to happen with these apps. Even if it happens there is always some monitoring installed and correction is done.EmptyWorkingSet function is particulary useful when recursion occurs, when you have large amount of assigned variables an you wanna deal with them fast on reentrance (I can demonstrate if you like).So, EmptyWorkingSet on current process in some particular cases. Other than that - really no needed. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Hammerfist Posted June 3, 2009 Author Share Posted June 3, 2009 (edited) EmptyWorkingSet function is particularly useful when recursion occurs, when you have large amount of assigned variables an you wanna deal with them fast on reentrance (I can demonstrate if you like).So, EmptyWorkingSet on current process in some particular cases. Other than that - really no needed.Agree with you. Thanks! Edited June 3, 2009 by Hammerfist My topics:<<<< Project ECO Helper >>>><<<< _ReduceMemory GUI >>>> Link to comment Share on other sites More sharing options...
ptrex Posted June 4, 2009 Share Posted June 4, 2009 @Hammerfist Still usefull according to me. I ran this regularly on a process like SKYPE. These kind of P2P applications like to be greedy if it comes up to memory consumption. Especially when you have your machine running for a long time. And performance wise this does not have any influence. Since those apps are sitting waiting in the background. So bottem line is that is does make sence on certain processes. And for others it doesn't. Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Hellooopsforgotsendcommand Posted November 21, 2009 Share Posted November 21, 2009 (edited) Thanks for this, I am going to try it on Firefox! Thanks I now use it as it works well with Firefox. Edited September 17, 2010 by Hellooopsforgotsendcommand 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