sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #03956
[Question #164795]: OutOfMemoryError with ant task
New question #164795 on Sikuli:
https://answers.launchpad.net/sikuli/+question/164795
I have created ant taskes for sikuli functions like sikuli.click, sikuli.doubleClick, etc...
I got OutOfMemoryError during execution of ant script using above sikuli ant tasks.
it works fine if your script is relatively small. but OutOfMerroyError issue occur when you execute large ant script involving hundreds of sikuli tasks.
if I set "ANT_OPTS" with bigger memory, it helps in short term. howerver OutOfMemoryError still occurs later.
I suspect sikuli objects are being created every time a skuli ant task is executed again & again on the JVM's heap. I am seeing this message "Sikuli vision engine loaded." for every single ant sikuli task.
Is there any way (API) for releasing/unloading vision engine to avoid JVM's OutOfMemory issue?
I would like to release/unload all of sikuli objects at the end of each ant task execution if possible.
here is the example of ant task I've wrriten:
import org.sikuli.script.*;
import java.lang.reflect.*;
import java.lang.Class;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
public abstract class SikuliTask extends Task {
private String img;
private int modifier;
private Integer timeout;
private String result;
private String timeoutProperty;
private String minSimilarityProperty;
private String moveMouseDelayProperty;
private String delayAfterDragProperty;
private String delayBeforeDropProperty;
private String slowMotionDelayProperty;
private String waitScanRateProperty;
private String observeScanRateProperty;
public SikuliTask() {
img=null;
result="sikuli.result";
timeoutProperty="sikuli.timeout";
timeout=null;
modifier=0;
minSimilarityProperty="sikuli.minSimilarity";
moveMouseDelayProperty="sikuli.moveMouseDelay";
delayAfterDragProperty="sikuli.delayAfterDrag";
delayBeforeDropProperty="sikuli.delayBeforeDrop";
slowMotionDelayProperty="sikuli.slowMotionDelay";
waitScanRateProperty="sikuli.waitScanRate";
observeScanRateProperty="sikuli.observeScanRate";
}
public void setMinSimilarityProperty(String minSimilarityProperty) {
this.minSimilarityProperty = minSimilarityProperty;
}
public String getMinSimilarityProperty() {
return this.minSimilarityProperty;
}
public void setMoveMouseDelayProperty(String moveMouseDelayProperty) {
this.moveMouseDelayProperty = moveMouseDelayProperty;
}
public String getMoveMouseDelayProperty() {
return this.moveMouseDelayProperty;
}
public void setDelayAfterDragProperty(String delayAfterDragProperty) {
this.delayAfterDragProperty = delayAfterDragProperty;
}
public String getDelayAfterDragProperty() {
return this.delayAfterDragProperty;
}
public void setDelayBeforeDropProperty(String delayBeforeDropProperty) {
this.delayBeforeDropProperty = delayBeforeDropProperty;
}
public String getDelayBeforeDropProperty() {
return this.delayBeforeDropProperty;
}
public void setSlowMotionDelayProperty(String slowMotionDelayProperty) {
this.slowMotionDelayProperty = slowMotionDelayProperty;
}
public String getSlowMotionDelayProperty() {
return this.slowMotionDelayProperty;
}
public void setWaitScanRateProperty(String waitScanRateProperty) {
this.waitScanRateProperty = waitScanRateProperty;
}
public String getWaitScanRateProperty() {
return this.waitScanRateProperty;
}
public void setObserveScanRateProperty(String observeScanRateProperty) {
this.observeScanRateProperty = observeScanRateProperty;
}
public String getObserveScanRateProperty() {
return this.observeScanRateProperty;
}
public void setImg(String img) {
this.img = img;
}
public String getImg() {
return this.img;
}
public void setDest(String dest) {
this.img = dest;
}
public String getDest() {
return this.img;
}
public void setApp(String app) {
this.img = app;
}
public String getApp() {
return this.img;
}
public void setTimeout(Integer timeout) {
this.timeout = timeout;
}
public Integer getTimeout() {
return this.timeout;
}
public void setTimeoutProperty(String timeoutProperty) {
this.timeoutProperty = timeoutProperty;
}
public String getTimeoutProperty() {
return this.timeoutProperty;
}
public void setModifier(int modifier) {
this.modifier = modifier;
}
public int getModifier() {
return this.modifier;
}
public void setResult(String result) {
this.result = result;
}
public String getResult() {
return this.result;
}
protected abstract void action() throws Exception;
protected void check() throws BuildException {
if(getImg() == null) {
throw new BuildException("[img/app] not provided.");
}
}
public void execute() {
if(timeout == null) {
if(getProject().getProperty(getTimeoutProperty()) == null) {
setTimeout(10);
} else {
setTimeout( Integer.parseInt(getProject().getProperty(getTimeoutProperty())) );
}
}
// minimum similarity of find operations
if(getProject().getProperty(getMinSimilarityProperty()) != null) {
Settings.MinSimilarity = Double.parseDouble( getProject().getProperty(getMinSimilarityProperty()) );
}
// waiting time after mouse down at the source location
if(getProject().getProperty(getDelayAfterDragProperty()) != null) {
Settings.DelayAfterDrag = Double.parseDouble( getProject().getProperty(getDelayAfterDragProperty()) );
}
// waiting time before mouse up at the target location
if(getProject().getProperty(getDelayBeforeDropProperty()) != null) {
Settings.DelayBeforeDrop = Double.parseDouble( getProject().getProperty(getDelayBeforeDropProperty()) );
}
// time taken for mose movement
if(getProject().getProperty(getMoveMouseDelayProperty()) != null) {
Settings.MoveMouseDelay = Float.parseFloat( getProject().getProperty(getMoveMouseDelayProperty()) );
}
// number of times actual search operations are performed per second
if(getProject().getProperty(getObserveScanRateProperty()) != null) {
Settings.ObserveScanRate = Float.parseFloat( getProject().getProperty(getObserveScanRateProperty()) );
}
// number of times actual search operations are performed per second
if(getProject().getProperty(getWaitScanRateProperty()) != null) {
Settings.WaitScanRate = Float.parseFloat( getProject().getProperty(getWaitScanRateProperty()) );
}
// duration of the visual effect (seconds)
if(getProject().getProperty(getSlowMotionDelayProperty()) != null) {
Settings.SlowMotionDelay = Float.parseFloat( getProject().getProperty(getSlowMotionDelayProperty()) );
}
check();
log("timeout : " + getTimeout());
log("result : " + getResult());
log("img/app : " + getImg());
try{
action();
getProject().setNewProperty(getResult(), "0");
}
catch (FindFailed e) {
log("cannot find image");
//e.printStackTrace();
getProject().setNewProperty(getResult(), "1");
}
catch (Exception e) {
//e.printStackTrace();
if(e.getMessage() != null) {
log(e.getMessage());
}
getProject().setNewProperty(getResult(), "1");
}
}
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.