dzlee Posted June 20, 2015 Share Posted June 20, 2015 (edited) hello autoit developers communityi have some question , i hope to find the answers of it :- in large project or even in small oneshow to make my compiled script use less memory ?- how to test my script and be sure that there is no memory leak , or whatsoever reduce my script performance ?- where can i find anything talks about autoit script architecture to avoid bad script design ?last thing i find these scriptcan anyone describe how these scripts work and is these script actually work finethanksFunc _ReduceMemory() Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId') Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0]) 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 Func _SelfReduceMemory() DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1) EndFunc Edited June 20, 2015 by dzlee Link to comment Share on other sites More sharing options...
water Posted June 20, 2015 Share Posted June 20, 2015 - where can i find anything talks about autoit script architecture to avoid bad script design ?The wiki has a section about good coding practices. dzlee 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
dzlee Posted June 20, 2015 Author Share Posted June 20, 2015 The wiki has a section about good coding practicesi am really grateful to youi take a look on it ,it's very helpfulthanks again bro Link to comment Share on other sites More sharing options...
water Posted June 20, 2015 Share Posted June 20, 2015 Glad to be of service We could even be more helpful if you could post your script. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
dzlee Posted June 20, 2015 Author Share Posted June 20, 2015 (edited) i'm about to start in storage management projectwhich i think will be a large scriptconnected to sqlite databaseand, the script will run on windows xp with 512MB ramso i am concerned in script performancethat's what i asked these question Edited June 20, 2015 by dzlee Link to comment Share on other sites More sharing options...
jchd Posted June 20, 2015 Share Posted June 20, 2015 Develop your application first, keeping in mind to use large variables wisely w.r.t. their lifetime. Use the power of SQLite internally instead of using AutoIt code to process large, raw output. The actual size of the .au3 code is almost irrelevant and you can always use stripping to remove unused parts from the runable code. Then only check if the result requires too much, search where the issue is and workout a way to decrease memory size for this part.The functions posted in the OP are not going to really help you, and possibly bite you someday. dzlee 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
dzlee Posted June 20, 2015 Author Share Posted June 20, 2015 i will try to do exactly what you saythank you for advice Link to comment Share on other sites More sharing options...
TheSpannish Posted June 20, 2015 Share Posted June 20, 2015 I think that if some parts of your script you add sleep() it wont use so much memory, the inconvenience its that it will take more time to load... If you are planning to use another program here I have a script that will reduce the memory of the program you say (its same as yours but you can select the program)Func _ProcessReduceMemory($iPID) Local $iProcExists = ProcessExists($iPID) If Not $iProcExists Then Return SetError(1, 0, 0) If IsString($iPID) Then $iPID = $iProcExists Local $hOpenProc, $aResult $hOpenProc = DllCall("Kernel32.dll", "int", "OpenProcess", "int", 0x1F0FFF, "int", False, "int", $iPID) $aResult = DllCall("Kernel32.dll", "int", "SetProcessWorkingSetSize", "hwnd", $hOpenProc[0], "int", -1, "int", -1) DllCall("Kernel32.dll", "int", "CloseHandle", "int", $hOpenProc[0]) If Not IsArray($aResult) Or $aResult[0] = 0 Then Return SetError(2, 0, 0) Return $aResult[0] EndFunc ;==>_ProcessReduceMemory dzlee 1 Codding its just my life! :thumbsup: Link to comment Share on other sites More sharing options...
water Posted June 20, 2015 Share Posted June 20, 2015 I think the best approach is to avoid memory leaks. Means: Release storage when it is no longer used.Set unused arrays to "" to release the memory, set unused objects to 0 to drop a connection, application or whatever. devilspride, RMENDES and dzlee 3 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
TheDcoder Posted June 20, 2015 Share Posted June 20, 2015 Also keep in mind that empty arrays take space too... Also develop a specific kind of programming pattern in your program if you are making a huge program, note that you don't have to plan your programming pattern first-hand, you will have to do it when you start coding your script, that ways its much easier. These are things which I follow when I code a big code hungry script. TD dzlee 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Developers Jos Posted June 20, 2015 Developers Share Posted June 20, 2015 Also keep in mind that empty arrays take space too... Also develop a specific kind of programming pattern in your program if you are making a huge program, note that you don't have to plan your programming pattern first-hand, you will have to do it when you start coding your script, that ways its much easier. These are things which I follow when I code a big code hungry script. This is as clear as mud to me but am sure there is some logic somewhere. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
water Posted June 20, 2015 Share Posted June 20, 2015 note that you don't have to plan your programming pattern first-hand, you will have to do it when you start coding your script, that ways its much easier.I would like to see one of your huge scripts made with this principles in mind. All we have seen until now are some small and simple scripts When trying to make good scripts/programs it is not about coding but planning. The design you make before you write the first line of code is what makes good code or in absence you get a pile of s..t sooner or later.Coding is less then 10% of the effort to write a good program. The rest is design, testing, documentation etcJust my 2 cents.. dzlee and SupaNewb 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
dzlee Posted June 20, 2015 Author Share Posted June 20, 2015 i understand it nowperformance about code design ,release resource ,use variables wisely ,make sqlite do the work for you ..thank you guys [solved] Link to comment Share on other sites More sharing options...
TheDcoder Posted June 21, 2015 Share Posted June 21, 2015 @Jos That way its much easier for you to start coding soon (earlier?)@water You are not going to see a huge script made by me anytime soon! TD EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
water Posted June 21, 2015 Share Posted June 21, 2015 TheDcoder,Do you start driving before you know where you want to go to?First comes planning, then comes doing. Wikipedia describes it much better: PDCA.Happy reading TheDcoder and dzlee 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2015 Share Posted June 21, 2015 In reference to the 2 scripts posted in this thread so far, neither one of them will actually reduce memory usage of your script. What both of them do is to take the memory that your program is using and dumping it to disk in the page file. In other words, it will reduce the RAM being used, but the data that was in the RAM is now in your page file, and being disk based it will make your program run much slower if if needs any of that information that on the disk. It's a band-aid on a bullet wound, you should try and fix any memory issues with your script before you resort to ruining its performance this way.In Windows XP memory management was terrible, so this type of script had limited usage. In today's modern OSs this is totally unnecessary because Windows handles the memory management and your scripts shouldn't try to do it. Microsoft is a lot smarter about memory management than you or I. Memory is usually plentiful, and much faster than disks, leave the data there and let Windows decide when it should page it out. argumentum and dzlee 2 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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