mikiutama Posted March 13, 2007 Posted March 13, 2007 (edited) if you dont mind... i've already done this... added to system tray and option for startup with windows... here: expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> Opt("TrayMenuMode",1) Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 Dim $ok1, $ok2, $ok3 Dim $memo = MemGetStats() $version = Chr(135) & " Memory Fusion " & Chr(135) If WinExists($version) Then Exit AutoItWinSetTitle($version) AutoItSetOption("WinTitleMatchMode", 2) TrayTip("","",1) TrayTip($version, "Right click for "&$version&" options...", 1, 1) TraySetClick(16) $info = TrayCreateItem($version) TrayCreateItem("") $dgui = TrayCreateItem("Open Memory Fusion") $def = TrayCreateItem("Defrag Memory") $rec = TrayCreateItem("Recover Memory") $str = TrayCreateMenu("Start with windows") $stry = TrayCreateItem("Yes", $str) $strn = TrayCreateItem("No", $str) $aut = TrayCreateMenu("Automatic Recover at") $10 = TrayCreateItem("10%", $aut) $20 = TrayCreateItem("20%", $aut) $30 = TrayCreateItem("Cancel", $aut) TrayCreateItem("") $out = TrayCreateItem("Exit "&$version) If @OSTYPE = "WIN32_WINDOWS" Then TrayItemSetState($aut, $TRAY_DISABLE) TrayItemSetState($rec, $TRAY_DISABLE) EndIf TraySetState() While 1 TraySetToolTip(" Summaries: "&@CRLF&""&@CRLF&" Total Memory "&Round($memo[1]/1024, 2)&" MB "&@CRLF&" Used Memory "&Round(($memo[1]-$memo[2])/1024, 2)&" MB "&@CRLF&" Free Memory "&Round($memo[2]/1024, 2)&" MB "&@CRLF&" Paging File "&Round($memo[4]/1024, 2)&" MB "&@LF) $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $info MsgBox(64, $version, "Memory Fusion is one smart memory optimizer that Defragments the memory in order to get that just-booted feeling without having to restart your PC. Memory Fusion lets you choose how to automatically recover the RAM when needed."&@CRLF&""&@CRLF&"Believe it or not, but there are 100's of programs out there that use similar techniques included within Memory Fusion."&@CRLF&""&@CRLF&"You don't have to have an extra memory tool installed anymore, because Memory Fusion will do the job as good as or even better than any other program."&@CRLF&""&@CRLF&"The ""Recover"" Button will perfrom the famous ""EmptyWorkingSet"" method"&@CRLF&""&@CRLF&"The ""Defrag"" Button will simply defrag your memory ") Case $msg = $dgui Memof() Case $msg = $def defg() Case $msg = $rec reco() Case $msg = $stry RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Memory_Fusion", "REG_SZ", @ScriptFullPath) Case $msg = $strn RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Memory_Fusion") Case $msg = $10 TrayItemSetState($20,$TRAY_UNCHECKED) TrayItemSetState($10,$TRAY_CHECKED) chee() Case $msg = $20 TrayItemSetState($10,$TRAY_UNCHECKED) TrayItemSetState($20,$TRAY_CHECKED) chef() Case $msg = $30 TrayItemSetState($10,$TRAY_UNCHECKED) TrayItemSetState($20,$TRAY_UNCHECKED) Case $msg = $out kill() ExitLoop EndSelect WEnd Exit Func Memof() $maing = GuiCreate(Chr(135) & " Memory Fusion " & Chr(135), 344, 275) GUICtrlCreateGroup ("Status", 5, 2, 335, 85) GUICtrlCreateLabel ("Used Memory", 15, 25, 235, 20) $inp1 = GUICtrlCreateLabel ("100%", 300, 25) $prog1 = GuiCtrlCreateProgress(105, 25, 175, 15) GUICtrlCreateLabel ("Free Memory", 15, 55, 235, 20) $inp2 = GUICtrlCreateLabel ("100%", 300, 55, -1, -1) $prog2 = GuiCtrlCreateProgress(105, 55, 175, 15) GUICtrlCreateGroup ("Info", 5, 90, 335, 85) GUICtrlCreateLabel ("Total Memory", 15, 115, 235, 20) GUICtrlCreateLabel ($memo[1] & "KB", 90, 115, 200, -1) GUICtrlCreateLabel ("Free Memory", 15, 145, 235, 20) $inp3 = GUICtrlCreateLabel ("", 90, 145, 200, -1) GUICtrlCreateLabel ("Used Memory", 205, 115, 115, 20) $inp4 = GUICtrlCreateLabel ("", 280, 115, 55, -1) GUICtrlCreateLabel ("Paging File", 205, 145, 115, 20) $inp5 = GUICtrlCreateLabel ("", 280, 145, 55, -1) $check1 = GUICtrlCreateCheckbox ("Automatically recover memory when it's less than 10%", 15, 185, 270, 20) If @OSTYPE = "WIN32_WINDOWS" Then GUICtrlSetState(-1, $GUI_DISABLE) $check2 = GUICtrlCreateCheckbox ("Automatically recover memory when it's less than 20%", 15, 210, 270, 20) If @OSTYPE = "WIN32_WINDOWS" Then GUICtrlSetState(-1, $GUI_DISABLE) $ok1 = GUICtrlCreateButton("Recover", 15, 240, 75, 20) If @OSTYPE = "WIN32_WINDOWS" Then GUICtrlSetState(-1, $GUI_DISABLE) $ok2 = GUICtrlCreateButton("Defrag", 130, 240, 75, 20) $ok3 = GUICtrlCreateButton("Exit", 250, 240, 75, 20) GuiSetState() $i=100 While 1 $i=$i+10 If $i > 100 Then $memo = MemGetStats ( ) $ramf = Round(100*($memo[1]-$memo[2])/$memo[1], 1) GUICtrlSetData ($prog1, $ramf) GUICtrlSetData ($inp1, $ramf & "%") $ramf = Round(100*($memo[2]/$memo[1]), 1) GUICtrlSetData ($prog2, $ramf) GUICtrlSetData ($inp2, $ramf & "%") GUICtrlSetData ($inp3, $memo[2] & "KB") $ramf = $memo[1]-$memo[2] GUICtrlSetData ($inp4, $ramf & "KB") GUICtrlSetData ($inp5, $memo[4] & "KB") $i=0 EndIf Sleep(25) $msg = GuiGetMsg() If GUICtrlRead($check1) = $GUI_CHECKED Then chee() If GUICtrlRead($check2) = $GUI_CHECKED Then chef() If $msg = $ok1 Then reco() If $msg = $ok2 Then defg() If $msg = $ok3 Then Exit If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Func reco() $list = ProcessList() For $i=1 To $list[0][0] If StringInStr($list[$i][0], "csrss") > 0 Or StringInStr($list[$i][0], "smss") > 0 Or StringInStr($list[$i][0], "winlogon") > 0 Or StringInStr($list[$i][0], "lsass") > 0 Then ContinueLoop ntmem($list[$i][1]) Next EndFunc Func ntmem($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 EndFunc Func defg() GUICtrlSetState($ok1, $GUI_DISABLE) GUICtrlSetState($ok2, $GUI_DISABLE) GUICtrlSetState($ok3, $GUI_DISABLE) $memo = MemGetStats ( ) $tot = Round($memo[1]/2.5) & "000" $fop = FileOpen("temp.vbs", 2) FileWrite($fop, "Space(" & $tot & ")") $clos = FileClose($fop) ClipPut("") Run("WScript.exe temp.vbs") ProcessWaitClose("WScript.exe") kill() EnvUpdate() GUICtrlSetState($ok1, $GUI_ENABLE) GUICtrlSetState($ok2, $GUI_ENABLE) GUICtrlSetState($ok3, $GUI_ENABLE) EndFunc Func chee() If 100 - $memo[0] < 10 Then reco() EndFunc Func chef() If 100 - $memo[0] < 20 Then reco() EndFunc Func kill() FileDelete("temp.vbs") EndFunc Edited March 13, 2007 by mikiutama
piccaso Posted March 13, 2007 Posted March 13, 2007 why not if the WSH is disabled, the dllcall will be used instead... no, dont use the crt functions i posted autoit has its own memory allocation function, i just forgot about it rather something like this:Func defg() GUICtrlSetState($ok1, $GUI_DISABLE) GUICtrlSetState($ok2, $GUI_DISABLE) GUICtrlSetState($ok3, $GUI_DISABLE) $memo = MemGetStats() DllStructCreate("byte[" & Round($memo[1] * 1024 / 2.5) & "]") ClipPut("") EnvUpdate() GUICtrlSetState($ok1, $GUI_ENABLE) GUICtrlSetState($ok2, $GUI_ENABLE) GUICtrlSetState($ok3, $GUI_ENABLE) EndFunc CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
magician13134 Posted March 13, 2007 Posted March 13, 2007 Why would you want to start when windows starts...? There's nothing to clean up then... Visit Magic Soft Inc. for some of my software
mikiutama Posted March 14, 2007 Posted March 14, 2007 Why would you want to start when windows starts...? There's nothing to clean up then...it will start with windows but it will not clean automatically unless you do it manually by pressing recover or setting up the limit (10% or 20%)...
mrbond007 Posted March 14, 2007 Author Posted March 14, 2007 When i try to defrag i get:Windows Script HostScript: ....\temp.vbsLine: 1Char: 1Error: Out of string space: 'Space'Code: 800A000ESource Microsoft VBScript runtime errorI tried setting the registry keys that Mr.Revoked mentioned, which incidentally did not exist until i made them.Try lowering the "Space" value in temp.vbs, this error happens when it tries to defrag more than half of the memory. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
mrbond007 Posted March 14, 2007 Author Posted March 14, 2007 Func defg() GUICtrlSetState($ok1, $GUI_DISABLE) GUICtrlSetState($ok2, $GUI_DISABLE) GUICtrlSetState($ok3, $GUI_DISABLE) $memo = MemGetStats ( ) $tot = Round($memo[1]/2.5) & "000" $fop = FileOpen("temp.vbs", 2) FileWrite($fop, "Space(" & $tot & ")") $clos = FileClose($fop) ClipPut("") Run("WScript.exe temp.vbs") ProcessWaitClose("WScript.exe") kill() EnvUpdate() GUICtrlSetState($ok1, $GUI_ENABLE) GUICtrlSetState($ok2, $GUI_ENABLE) GUICtrlSetState($ok3, $GUI_ENABLE) EndFunc oÝ÷ Øh¢F¥¢¶Øb±»Æ§ßÛ`zØr¥w*.{ej)á£aDZiËeË +©Ý{^r&¥ÊØb²«µ«¢+Ø(ÀÌØíµµ¼ô5µÑMÑÑÌ ¤(ÀÌØíѽÐôI½Õ¹ ÀÌØíµµ½lÅt¼È¸Ô¤µÀìÅÕ½ÐìÀÀÀÅÕ½Ðìì±Ðì´´Ý¡ä¥ÌÑ¡¥ÌüÝ¡äÅÕ½Ðì¼È¸ÔÅÕ½Ðì¹ÌäìµÀìÅÕ½ÐìÀÀÀÅÕ½ÐìÌäì(ÀÌØí½Àô¥±=Á¸ ÅÕ½ÐíѵÀ¹ÙÌÅÕ½Ðì°È¤)¥±]É¥Ñ ÀÌØí½À°ÅÕ½ÐíMÁ ÅÕ½ÐìµÀìÀÌØíѽеÀìÅÕ½Ðì¤ÅÕ½Ðì¤ì±Ð촴ݡСÌÑ¡ÌäíMÁ ¤Ìäìչѥ½¸Ñ¼¼Ý¥Ñ Ñ¡¥Ìü( Arjan Creates a file called "temp.vbs", writes to the file : Space($value) : the $value must not exceed 1/2 of your total memory(example Space(200000000) = 200MB) Round($memo[1]/2.5) & "000" will be something like = 204000000 if you have 512MB Space() is a dirty microsoft trick. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
mrbond007 Posted March 14, 2007 Author Posted March 14, 2007 please dont get me wrong, i dont dislike your script or something.I just cant believe its that easy... Dirty tricks ey i played around with similar tools (and a debugger), they use VirtualAlloc stuff to allocate memory.there is probably something true behind this theory i was searching for articles on that topic but i didnt find anything usefull, but i didnt check out the site you mentioned jet. but that cant be true.WScript.exe probably calls more api's just for creating a process then what would be necessary to do it via dllcall.Well i didnt benchmark it but thats why fastcgi was invented.ok fastcgi is way off topic and dont know if process spawning time was a problem on the windows platform.so i probably have to compare it to proof it edit:after thinking a bit about it...DllStructCreate is probably the fastest the website has changed to http://www.microsuck.com Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
mrbond007 Posted March 21, 2007 Author Posted March 21, 2007 Updated to version 2. i added a nice task manager to show the memory-hungry processes & added "F5" as hotkey to refresh the process list. It's a little bit slower but does the job right. Enjoy Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
piccaso Posted March 21, 2007 Posted March 21, 2007 (edited) looks nice still using old space() ey if it makes you happy...but you probably didnt notice that HotKeySet() hotkeys are global.and if you have this tool in the tray you wont be able to use F5so here is a correction:Memory Fusion V2 2KXP.zip (2.9K) Number of downloads: i also made it go to tray on startup.You dont really want to free up memory after booting right?edit:since your still addicted to Space() how about that one?Func _vbs_init() Local $sVbs = "Public Function myspc(iSize)" & @CRLF _ & " myspc = Space(iSize) " & @CRLF _ & "End Function " & @CRLF Local $oVbs = ObjCreate('ScriptControl') If @error Then Return SetError(1, 0, 0) $oVbs.language = 'vbscript' $oVbs.addcode ($sVbs) Return $oVbs EndFunc Func _vbs_space(ByRef $oVbs, $iSize) Return $oVbs.Run ("myspc", $iSize) EndFunc $oVbs = _vbs_init() ConsoleWrite(StringLen(_vbs_space($oVbs, 50)))... it acts just like Edited March 21, 2007 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
mrbond007 Posted March 21, 2007 Author Posted March 21, 2007 thanks a lot for your help Picasso I'm still not finished with the script, more to come. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
mrbond007 Posted April 2, 2007 Author Posted April 2, 2007 @Picasso Iv'e done some extensive research about Space(), and it turned out that it was originally made for 95/98 only, but microsoft forgot to remove it from newer versions . Your function however works only on 2000 and up (maybe NT but not sure). I tested other memory programs and boy was i surprised, most of them simply generates random-garbage like prewritten "0123456789ABCD....." and they use this instead of Space(), and when the memory is almost full windows jumps in and unfragmentes the memory (i think that windows rebuilds the toolbox calls also but i'm not 100% sure). Only a handfull of memory programs out there use true methods like dllcalls. That's why we see nice looking programs out there that use simillair methods and they clame that they have done a miracle of some kind L.O.L I also used your function to create a memory stress test(for testing purposes only), after i saw "MemoryTest", a nice freeware to test the memory for errors Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
piccaso Posted April 2, 2007 Posted April 2, 2007 as far as i understand this it doesent matter how you allocate memory and windows doesent act different if memory is nulled or contains random stuff. as conclusion i would recommend DllStructCreate() to do that task because it comes with autoit CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
mrbond007 Posted April 3, 2007 Author Posted April 3, 2007 Guess you're right but i'm not that good with Dll stuff Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
mrbond007 Posted June 4, 2007 Author Posted June 4, 2007 Updated Again Say goodbye to VBS crap Now we use the built-in AutoIt Memory Management Functions . Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
Raik Posted October 4, 2007 Posted October 4, 2007 @ mrbond007ask yourself:what is the difference between ram an a harddisk?what is defragmentation and why is it bad on harddisks?how works a hardisk and how works ram?what will your program REALY do?what means "swapping", what for is the swap-file?does your program speed up the pc?will you be able, to write me a program, witch quadruples my ram and let my cpu computing 10 times faster without overclocking? AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)
mrbond007 Posted October 5, 2007 Author Posted October 5, 2007 ask yourself:what is the difference between ram an a harddisk?what is defragmentation and why is it bad on harddisks?how works a hardisk and how works ram?what will your program REALY do?what means "swapping", what for is the swap-file?hemmm the difference between ram and harddisk ???I already know these information cause i googled them does your program speed up the pc?will you be able, to write me a program, witch quadruples my ram and let my cpu computing 10 times faster without overclocking?no memory fusion defrags and recovers the memory. get the last version from the autoit download page. You want a program that will speed your pc up to 10 times , well it's possible to get some extra speed if you use older windows versions like win98.Added to my todo list Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
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