← Back to team overview

sikuli-driver team mailing list archive

[Question #403943]: Stable increasing memory - Hang script!!

 

New question #403943 on Sikuli:
https://answers.launchpad.net/sikuli/+question/403943

Hello.! I got a stable increasing memory.It starts the script from 400mb ram and in 4hours increased to 2,50gb ram and then hangs the Mac. The mac has 4gb ram and 10.10 osx. I run script  from command this: java -jar ~/Desktop/Myapp/sikulixapi.jar -r ~/Desktop/Myapp/test.sikuli

I believe its not the JVM but set in the code..please help!!!


Here is the script:

#-----Detecting Os - Specifications-------#
from org.sikuli.natives import Vision
Vision.setParameter("MinTargetSize", 6) # the default is 12.

Settings.ActionLogs=0
Settings.InfoLogs=0
Settings.DebugLogs=0

myos = Settings.isMac()
if myos == True:
	print("#Detected Mac OSX...START")
else:
	popup("#Not detected Mac..EXIT")
	exit()


regblueline = Region(602,315,100,150) #βρικει την μπλε γραμμη του error
clicktoavoiderrordone = Region(1280,95,2,2) #παταει επανω δεξια για ασφαλεια
clickendbattle = Region(111,582,36,20) #κουμπι κλικ για endbattle κοκκινο και end για error
findtroopsfull =  Region(56,136,50,50) #reg για αν γεμισαν τα troops
tabtraintroops = Region(480,100,2,2) #reg για το tab_traintroops
soldierreg = Region(100,460,50,50) #reg για να προσθεσει η να τσεκαρει troops
regclosetroops = Region(1200,90,2,2) #reg για να κλεισει το παραθυρο troops ολο
arm = Region(181,88,35,26) #reg για να παει στο tab_army
swordreg = Region(50,580,2,2) #reg για να πατησει το σπαθι
btnhome = Region(638,674,23,25) #reg για το κουμπι returnhome-τελιωσε η μαχη
screenok = Region(1196,455,81,80) #reg για αν ειμαστε στην αρχικη οθονη
regfindloot = Region(142,152,43,18) #reg για να βρει το καταλληλο loot
nextfindbattlebtn = Region(1110,560,2,2) #reg για να κλικ σε επομενη αναζητηση βασης
regmap = Region(90,690,2,2) #reg παταει στον χαρτη για επιθεση
findmatchbtn = Region(300,598,2,2) #reg παταει στο κουμπι find-match
attackreg = Region(173,67,920,570) #η περιοχη που ψαχνει για τα σημεια
collect = Region(105,125,980,570) #reg για το collect στην αρχη



#______________Variables Attack_Find_Red_Points START____________________#
count = 0
FindLoot = "FindLootBattleV1.png"
FastClickPoint = "1476737265836.png"
campsfull = "1476660328402.png"
onceplay = False
popupcoc = "wifierrorcircle.png"
popupcoca = "bluelineerror.png"
OriginalBaseFind = "originalbasedone.png"
Returnhomeendbattle = "Returnhomeendbattle.png"
Endbattle = "Endbattle.png"
blacksold = "blacksoldier.png"
Surrender = "surrender.png"
import random
random.seed()
#αποθηκευουμε τις συντεταγμενες των σημειων
Apointattack = ""
Bpointtattack = ""
Cpointattack = ""
Dpointattack = ""
Epointattack = ""
Fpointattack = ""
#------------#
#αν ειναι ισο η πανω απο 3 σημεια κανε επιθεση αλλιως ειναι false
goforattack = True
#τα δειγματα για τα σημεια
Redpoint1 = "red1.png"
Redpoint2 = "red2.png"
Redpoint3 = "red3.png"
RedPoint4 = "RedPoint4.png"
RedPoint5 = "RedPoint5.png"
RedPoint6 = "RedPoint6.png"
#------------#





#<------THE OBSERVE OPERATION-------->
def handler(event):
    global count
    count = 1
    wait(2)
    print("#Observe Error")
    clicktoavoiderrordone.click() #κλικ βασικο σφαλματος
    wait(2)
    event.stopObserver()
    regblueline.observe()
    return count

regblueline.onAppear(Pattern("bluelineerror.png").exact(),handler)
regblueline.onAppear(Pattern("wifierrorcircle.png").exact(),handler)
regblueline.observe(background = True)





       

#------START------#
def Model():
    global count
    while True:
        if screenok.exists(Pattern(OriginalBaseFind).exact()):
            clicktoavoiderrordone.click()
            print("#Starting the program...")        
            break
        else:
            print("Waiting for the Original Base...")
            clicktoavoiderrordone.click() #κλικ βασικο σφαλματος
            wait(5)
            continue

    #<<-----------CREATE------------->>#
    #print("#Prepare for Building")
    wait(0.5)
    clicktoavoiderrordone.click()
    wait(1)
    keyDown(Key.CMD)
    wheel(WHEEL_UP, 30)
    keyUp()
    wait(1)
    rnmtime = random.randint(2, 5)
    wait(rnmtime)
    wait(1)
    wait(0.1)
    swordreg.click()

    if count == 1:
        return count

    while True:
        wait(0.4)
        if findtroopsfull.exists(campsfull,0):
            print("#Base is Full...")
            rnmtime = random.randint(1, 2)
            wait(1)
            tabtraintroops.click()
            if count == 1:
                return count
            wait(1)
            if soldierreg.exists(Pattern(blacksold).similar(0.95)):
                wait(1)
                #regclosetroops.hover()
                regclosetroops.click()
                if count == 1:
                    return count
            else:
                if count == 1:
                    return count
                soldierreg.hover()
                mouseDown(Button.LEFT)
                wait(4)
                hover(FastClickPoint)
                mouseUp()
                wait(1)
                #regclosetroops.hover()
                regclosetroops.click()
                wait(0.7)
                
                if count == 1:
                    return count
            break
            clicktoavoiderrordone.click()
            if count == 1:
                return count
        else:
            
            wait(1)
            #tabtraintroops.hover()
            tabtraintroops.click()
            if count == 1:
                return count
            
            if soldierreg.exists(Pattern(blacksold).similar(0.95)):
                wait(0.7)
                arm.click()
                onceplay = True
                if count == 1:
                    return count                
            else:
                if count == 1:
                    return count
                onceplay = True
                print("#Adding Soldiers...")
                wait(1)
                soldierreg.hover()
                mouseDown(Button.LEFT)
                wait(4)
                hover(FastClickPoint)
                mouseUp()
                wait(1)
                arm.click()
                
                if count == 1:
                    return count

                if exists(Pattern(OriginalBaseFind).exact()):
                    wait(1)
                    #swordreg.hover
                    swordreg.click()
                    wait(1)
                    #tabtraintroops.hover()
                    tabtraintroops.click()
                    wait(1)
                    print("#Adding Soldiers...")
                    soldierreg.hover()
                    mouseDown(Button.LEFT)
                    wait(4)
                    hover(FastClickPoint)
                    mouseUp()
                    wait(1)
                    arm.click()
                    onceplay = True
                    if count == 1:
                        return count
                else:
                    pass
                        
            if count == 1:
                return count
            
            if onceplay == True:
                print("#Waiting Soldiers to Complete...")
                while True:
                    if findtroopsfull.exists(Pattern(campsfull).exact()):
                        break
                    else:
                        if count == 1:
                            return count
                        continue
            else:
                pass
    wait(1.2)


    #--------


    #<<-------------SEARCH ----------->>#

    print("#Begin Search...")

    regmap.click()
    wait(1)
    findmatchbtn.click()
    while True:
        while True:
            wait(0.3)
            if clickendbattle.exists(Endbattle,0):
                print("#Keep Looking...")
                break
            else:
                if count == 1:
                    return count
                continue
        wait(0.8)
        if regfindloot.exists(FindLoot,0):
            print("#Find Enemy!!!")
            break
            
            if count == 1:
                return count
        else:
            nextfindbattlebtn.click()
            clickendbattle.waitVanish(Endbattle)
            #print("#Dont Found Loot")
            if count == 1:
                return count
            continue

     #-------END OF SEARCH------#

    #αποθηκευουμε αν δεν υπηρξε σημειο για το αν θα επιτεθει
    p1 = 0
    p2 = 0
    p3 = 0
    p4 = 0
    p5 = 0
    p6 = 0
    #το συνολο των σημειων που βρηκαμε για το αν θα επιτεθει
    sump = 0
    #------------#
    #αποθηκευουμε αν οντως υπαρχει σημείο
    getpointa = 0
    getpointb = 0
    getpointc = 0
    getpointd = 0
    getpointe = 0
    getpointf = 0
        #------------#


    #<<-----------FIND POINT------------->>#
    print("#Organizing Attack...")
    if count == 1:
        return count
        
    if attackreg.exists(Redpoint1,0):
        try:
            attackreg.hover(Redpoint1) #ΒΡΗΚΕ ΣΗΜΕΙΟ ΚΟΚΚΙΝΟ 1
            Apointattack = Env.getMouseLocation() #ΑΠΟΘΗΚΕΥΣΕ ΤΙΣ ΣΥΝΤΕΤΑΓΜΕΝΕΣ ΤΟΥ ΣΗΜΕΙΟΥ
            getpointa = 1
            print("#1 Thesis...")
        except:
            getpointc = 0
    else:                
        p1 = 1
        print("#Error 1...")
        
    if attackreg.exists(Redpoint2,0):
        try:
            attackreg.hover(Redpoint2)
            Bpointattack = Env.getMouseLocation()
            getpointb = 1
            print("#2 Thesis...")
        except:
            getpointc = 0
    else:                
        p2 = 1
        print("#Error 2...")
        
    if attackreg.exists(Redpoint3,0):
        try:
            attackreg.hover(Redpoint3)
            Cpointattack = Env.getMouseLocation()
            getpointc = 1
            print("#3 Thesis...")
        except:
            getpointc = 0
    else:                
        p3 = 1
        print("#Error 3...")

    if attackreg.exists(RedPoint4,0):
        try:
            attackreg.hover(RedPoint4)
            Dpointattack = Env.getMouseLocation()
            getpointd = 1
            print("#4 Thesis...")
        except:
            getpointc = 0
    else:                
        p4 = 1
        print("#Error 4...")

    if attackreg.exists(RedPoint5,0):
        try:
            attackreg.hover(RedPoint5)
            Epointattack = Env.getMouseLocation()
            getpointe = 1
            print("#5 Thesis...")
        except:
            getpointc = 0
    else:                
        p5 = 1
        print("#Error 5...")
           
    if attackreg.exists(RedPoint6,0):
        try:
            attackreg.hover(RedPoint6)
            Fpointattack = Env.getMouseLocation()
            getpointf = 1
            print("#6 Thesis...")
        except:
            getpointc = 0
    else:                
        p6 = 1
        print("#Error 6...")
    if count == 1:
        return count

    #AN ΒΡΗΚΕ =>3 ΤΟΤΕ ΒΑΡΑ ΘΕΩΡΗΤΙΚΑ
    sump = p1 + p2 + p3 + p4 + p5 +p6
    print(sump)
    if sump <= 3:
        print("#Got>Thesis...")
        goforattack = True
    else:
        print("#Got<Thesis...")
        goforattack = False
    if count == 1:
        return count
        
        
        

    #<<---------GO--------------->>#
        
    if goforattack == True:
        print("#Starting Attack!!")
    else:
        if count == 1:
            return count
        count = 1
        print("#Not Enough Thesis...EXIT")
        
    rnmtimea = random.randint(1, 2)
    #----DROP THE SOLDIERS----#
    if getpointa == 1:
        attackreg.hover(Apointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count
    else:
        pass
    if getpointb == 1:
        attackreg.hover(Bpointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count			
    else:
        pass
    if getpointc == 1:
        attackreg.hover(Cpointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count           
    else:
        pass
    if getpointd == 1:
        attackreg.hover(Dpointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count          
    else:
        pass
    if getpointe == 1:
        attackreg.hover(Epointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count           
    else:
        pass
    if getpointf == 1:
        attackreg.hover(Fpointattack)
        mouseDown(Button.LEFT)
        wait(4)
        mouseUp()
        wait(rnmtimea)
        if count == 1:
            return count          
    else:
        pass
        #-----#        
    if count == 1:
        return count

    #<<----------WAIT TO FINISH-------------->>#
    while True:
        if btnhome.exists(Returnhomeendbattle,0):
            rnmtime = random.randint(1, 2)
            wait(rnmtime)
            btnhome.click()
            wait(1)                
            print("#Going Home...")
            if count == 1:
                return count
            
            break
        elif count == 1:
            return count
        else:
            continue

    return None


        #<<-----------MAIN ERROR SOLVER------------->>#
def ModelSolver():
    print("Solving the Error...")
    while True:
        if regblueline.exists(Pattern(popupcoc).exact()):
            print("#Error Wifi...")
            clicktoavoiderrordone.click() #κλικ βασικο σφαλματος wifi
            wait(2)
        elif regblueline.exists(popupcoca,0):
            print("#Error Break...")
            clicktoavoiderrordone.click() #κλικ βασικο σφαλματος blueline
            wait(2)
        else:
            break
    wait(1)
    
    if btnhome.exists(Returnhomeendbattle,0): # ειμαστε στο τελος μαχης(homegreenbutton)
        wait(0.3)
        btnhome.click()
        print("#Error Exit...")
    elif clickendbattle.exists(Endbattle,0): #ειμαστε στο ψαξιμο μαχης endbattle
         wait(0.3)
         clickendbattle.click()
         print("#Error Exit...")
    elif clickendbattle.exists(Surrender,0): #ειμαστε στην ενεργη μαχη surrender
         wait(0.3)
         clickendbattle.click()
    else:
         print("Continue from Error...")

    while True:
        if screenok.exists(Pattern(OriginalBaseFind).exact()):
            clicktoavoiderrordone.click()
            print("#Error Solved Success...")        
            break
        elif regblueline.exists(popupcoca,0):
            print("#Error Exit...")
            clicktoavoiderrordone.click() #κλικ βασικο σφαλματος blueline
            #print("2 CLICKED SAFE CLICK")
            wait(5)
        else:
            print("#Waiting the Call...")
            clicktoavoiderrordone.click()
            wait(5)
    count = 0
    return count
#--------END OF SOLVER--------#











for tt in range(150):
    if count == 0:
        Model()
    else:
        ModelSolver()
        count = 0
        continue




            
                    





-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.