← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #666773]: How to get on the road as a newcomer to Java programming

 

Question #666773 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/666773

RaiMan posted a new comment:
Java has an automatic garbage collection (GC) at the top controlled by
object's reference counts: in the moment an object is no longer
referenced (ref count 0), it will become a candidate for GC (but it is
not predictable when in the future it will really purged from memory
(see the Java limits)).

so if you have something like that:

while(true) {
    Match match = someRegion.find(new Pattern(someImg).similar(0.9))
}

end loop 1:
match references new object match1
anonymous object Pattern only lives until find() returns - hence GC'd (no outside reference)

end loop 2:
match 1 GC'd
match references new object match2
Pattern same as before

.... and so on

The role of images:
- a captured image (file name) is loaded to memory when first used and then cached for reuse
- a used region (someRegion here) holds the screenshot last used for search (size depends on region size)

So in your "simple case" you might run it for years ;-) and your machine
should show about 300MB memory consumption for the Java process run from
commandline. Running it from within the IDE it might be a bit more of
course.

... and a screenshot of the whole screen costs about pixel width *
height * 4 bytes ;-)

Feel free to use the respective tools in your IDE or the task-manager to
watch.

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