SikuliX1 icon indicating copy to clipboard operation
SikuliX1 copied to clipboard

IDE: possible memory leak with long running scripts

Open RaiMan opened this issue 5 years ago • 3 comments

originally filed on Launchpad

another discussion on launchpad

Possible workarounds (Java 11+)

- start the IDE normally and run your script in the IDE

- in $JAVA_HOME/bin there is a command jcmd

- in parallel to the running script run it in a terminal as $JAVA_HOME/bin/jcmd without any parameters
   and you will get the active JVMs

- find the pid for the JVM running org.sikuli.ide.SikulixIDE

- from time to time in the same terminal window run
   jcmd <IDE-PID> GC.run

This should run a garbage collection and the memory usage should be at a lower level afterwards.
... or you might trigger the garbage collection directly inside the script:

import java.lang.System as JSYS # at beginning of main script

JSYS.gc() # at loop start or loop end

... or somewhere else, where it makes sense.

RaiMan avatar Mar 05 '20 14:03 RaiMan

this is a script related to https://answers.launchpad.net/sikuli/+question/692550

Reg=Region(1400+0,675,365,51)
Reg.highlight(2)

import java.lang.Runtime as RT
jrt = RT.getRuntime()
print "max:", jrt.maxMemory(), "tot:", jrt.totalMemory(), "free:", jrt.freeMemory()

for i in range(1,2000):
    Reg.text()
    if i % 50 == 0:
        print i, "free:", int(jrt.freeMemory()/(1024 * 1024)) 

RaiMan avatar Aug 24 '20 15:08 RaiMan