Sign in to follow this  
Followers 0
zFrank

optimise and reduce memory usage

11 posts in this topic

#1 ·  Posted (edited)

in my script i need to close and show many windows.

i used

$filter = "Test|First|Second|etc" ;and many others too
$i = 50
While Sleep(1000); check every second
    If WinExists("[REGEXPTITLE:(?i)" & $filter & "]") Then
        WinClose("[last]")
        $i -= 1
        If $i = 0 Then ExitLoop
        MsgBox(0, "example", "Test"
    EndIf
WEnd

i need to use around 30 more words but it is taking 95% cpu usage and ram usage.

i have to run the window check until i finds the window of my choice.

i also added sleep but adding sleep slows the process and also script uses 85-95%

please give me a suggestion on how can i reduce the cpu usage.

thanks.

Edited by zFrank

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites



I tested this script it uses 1%cpu

$filter = "Test|First|Second|etc" ;and many others too
$i = 50
While 1
    Sleep(1); check every second
    If WinExists("[REGEXPTITLE:(?i)" & $filter & "]") Then
        WinClose("[last]")
        $i -= 1
        If $i = 0 Then ExitLoop
        MsgBox(0, "example", "Test")
    EndIf
WEnd

Share this post


Link to post
Share on other sites

but as i told before i also have around 30 more words. this was just a example script.

2nd : Maybe you have tested it on a very high end pc.

please give any solution for it.


[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

this script will run in a office on 100 computers.

their config is... as follow

Win98 , 500mhz processor and 128mb ram.

because in this office there is no need of high quality pcs. but this is a problem/challenge for me. i hope any good and/or expert will help me.

Edited by zFrank

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites

i think you problem is the sleep (1)

sleep is in milliseconds not in seconds

increase the value to 1000 and try again


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

okkk, my problem is not solved it still uses 90% after giving Sleep(1000) and i can't give it more Sleep() please give any other solution.


[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites

okkk, my problem is not solved it still uses 90% after giving Sleep(1000) and i can't give it more Sleep() please give any other solution.

$A = 1
While $A < 3
    $B = 1
    While $B < 580
               if winexists("Test") Then
               WinClose("Test")
               ElseIf winexists("Example") Then
                     WinClose("Example")
               EndIf
               if winexists("Test33") Then
               ExitLoop
           EndIf 
           Sleep(25)
       Wend
       Sleep(25)
Wend

Sleep your script 25 miliseconds in every loop, and memory usage will be reduced.

For me is between 6% and 9% CPU Usage.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0