gajendravaradhan / sikuli-api

Automatically exported from code.google.com/p/sikuli-api
0 stars 0 forks source link

[Sikuli Java API] Using Sikuli causes memory heap error.. #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.I'm using Sikuli in Windows 64 Bit machine and When I'm continue to run a 
long test, it causes memory heap error in Java.

Whenever using DesktopRegion(), it almost consumes 3MB of heap memory and not 
releasing it causing heap memory issue while running tests.

Kindly provide me the correct Sikuli jar file which has resolved this memory 
leak issue...

Its very urgent..Please reply  ASAP..

Memory heap error issue happens all time and unable to complete test
execution.

Using sikuli-api-1.0.2-stanlalone.jar and sikuli-script.jar from
Sikuli-r930-win32 in Windows 64 bit.

Let me know which sikuli jar to be used to overcome this issue. Its very
urgent..

java.lang.OutOfMemoryError: Java heap space
        at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:92)
        at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:415)
        at java.awt.image.Raster.createWritableRaster(Raster.java:944)
        at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1073)
        at javax.imageio.ImageReader.getDestination(ImageReader.java:2896)
        at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1280)
        at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1577)
        at javax.imageio.ImageIO.read(ImageIO.java:1448)
        at javax.imageio.ImageIO.read(ImageIO.java:1352)
        at org.sikuli.api.robot.desktop.DesktopScreen.getScreenshot(DesktopScreen.java:35)
        at org.sikuli.api.DefaultScreenRegion.capture(DefaultScreenRegion.java:126)
        at org.sikuli.api.ImageTarget.getUnordredMatches(ImageTarget.java:122)
        at org.sikuli.api.DefaultTarget.doFindAll(DefaultTarget.java:93)
        at org.sikuli.api.DefaultScreenRegion._find(DefaultScreenRegion.java:73)
        at org.sikuli.api.DefaultScreenRegion.access$100(DefaultScreenRegion.java:29)
        at org.sikuli.api.DefaultScreenRegion$RepeatFind.run(DefaultScreenRegion.java:110)
        at org.sikuli.api.DefaultScreenRegion.wait(DefaultScreenRegion.java:119)
        at com.pch.bingo.elements.FlashSikuliDriver.GetCurrentScreeen(FlashSikuliDriver.java:128)
        at com.pch.bingo.elements.FlashSikuliDriver.Displayed(FlashSikuliDriver.java:174)
        at com.pch.bingo.elements.FlashButton.Displayed(FlashButton.java:65)
        at com.pch.bingo.flows.HomeFlow.ContinueAndStartGame(HomeFlow.java:3729)
        at com.pch.bingo.flows.HomeFlow.PlayAllGames(HomeFlow.java:829)
        at com.pch.bingo.test.ui.Reg51Invalid_OR_NullScenario.Reg51Invalid(Reg51Invalid_OR_NullScenario.java:120)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

Original issue reported on code.google.com by saranyab...@gmail.com on 20 May 2013 at 7:05

GoogleCodeExporter commented 8 years ago
Which OS are you running your test?

Original comment by nikhil....@gmail.com on 24 May 2013 at 8:29

GoogleCodeExporter commented 8 years ago
Hi

Thanks for your quick consideration.

I'm using Sikuli in two different machines with  the Windows OS with 32 Bit
and 64 Bit respectively.

Kindly provide me the solution to overcome heap memory. Since I worked on
lot of work around in my machine it didn't help. Sikuli consumes 3MB heap
memory for every DesktopScreenRegion() action.

Its very urgent because I made development using Sikuli and I cannot revert
it back. Please help in this regard.

Original comment by saranyab...@gmail.com on 26 May 2013 at 5:40

GoogleCodeExporter commented 8 years ago
Here is a pre-release version that contains a fix.
https://bitbucket.org/doubleshow/sikuli-api/downloads
Please download and report whether the problem is solved.

Original comment by doubles...@gmail.com on 13 Jun 2013 at 9:54

GoogleCodeExporter commented 8 years ago
Hi 

Still issue is not resolved. when We try to click Element which was done using 

DesktopScreenRegion() action, It consumes nearly 3MB of heap memory and 
releasing 

not that memory. Issue is because Sikuli consumes heap memory and not releasing 
it 

up or cleaning it after the action done.

Let me know if you any information further. 

Original comment by saranyab...@gmail.com on 14 Jun 2013 at 12:50

GoogleCodeExporter commented 8 years ago
This is the piece of code we used to test. We were able to run this for a long 
time without causing any out of memory problem. 

public static void testRepeatedFindOnDifferentScreenRegionObjects(){
        Runtime runtime = Runtime.getRuntime();

        while (true){
            ScreenRegion s = new DesktopScreenRegion();     
            Target target = new ImageTarget(new File("large.png"));
            s.wait(target, 100);                        
            System.out.println("heap MB: " + (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024);
        }

    }

The sample output:
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 34
heap MB: 50
heap MB: 52
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 50
heap MB: 52
heap MB: 28
heap MB: 46
heap MB: 48
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 33
heap MB: 51
heap MB: 53
heap MB: 34
heap MB: 52
heap MB: 53
heap MB: 34
heap MB: 52
heap MB: 53
heap MB: 33
heap MB: 52
heap MB: 53
heap MB: 34
heap MB: 50
heap MB: 52

The heap consumption is hovering at about 50.

Also, if you force garbage collection by adding System.gc(), like:

        Runtime runtime = Runtime.getRuntime();     
        while (true){
            ScreenRegion s = new DesktopScreenRegion();     
            Target target = new ImageTarget(new File("large.png"));
            s.wait(target, 100);
            System.gc();
            System.out.println("heap MB: " + (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024);
        }
>>
The memory consumption is stable at around 11.

heap MB: 11
heap MB: 11
heap MB: 11
heap MB: 11
heap MB: 11

Please let me know if you observe a similar behavior on your system.

Original comment by doubles...@gmail.com on 14 Jun 2013 at 1:40

GoogleCodeExporter commented 8 years ago
Hi 

Thanks for your quick reply. Am using Canvas object to locate element first 
before click event. Let me try again by removing canvas object and try like as 
you mentioned and run garbage collector and let you know.

Regards,
Saranya.s

Original comment by saranyab...@gmail.com on 14 Jun 2013 at 2:37

GoogleCodeExporter commented 8 years ago
Hi

I tried using the above code. It works fine. But if implement "click()" 
function and run tests, it actually consumes heap memory a lot as I mentioned 
earlier. Could you please check by implementing "Click()" after 

ScreenRegion s = new DesktopScreenRegion();     
Target target = new ImageTarget(new File("large.png"));
s.wait(target, 100);

Waiting for your reply.

Thanks
Saranya

Original comment by saranyab...@gmail.com on 17 Jun 2013 at 3:34

GoogleCodeExporter commented 8 years ago
I am unable to reproduce the error.
I ran this code:

        Runtime runtime = Runtime.getRuntime();
        Mouse mouse = new DesktopMouse();
        while (true){
            ScreenRegion s = new DesktopScreenRegion();     
            Target target = new ImageTarget(new File("debug.png"));
            List<ScreenRegion> rs = s.findAll(target);
            if (rs.size() > 0){
                ScreenRegion r = rs.get(0);
                mouse.click(r.getCenter());
                System.out.println("r = " + r);         
            }
            System.gc();
            System.out.println("heap MB: " + (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024);
        }

The output is:
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8070441484451294}
heap MB: 6
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8528084754943848}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8528084754943848}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8528084754943848}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8528084754943848}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8447399735450745}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8528084754943848}
heap MB: 10
r = 
DefaultScreenRegion{screen=org.sikuli.api.robot.desktop.DesktopScreen{id=0}, 
x=1310, y=45, width=57, height=30, score=0.8070441484451294}
heap MB: 10

I did not observe any memory consumption problem. Please try it yourself and 
let us know.

Original comment by doubles...@gmail.com on 18 Jun 2013 at 2:12

GoogleCodeExporter commented 8 years ago
Hi

Thanks for your reply regarding this issue. 

This issue has been resolved in Windows 64 - Bit OS.

 But in 32 - Bit OS it still remains the same in consuming heap memory

[@Click] heap MB: 59
[@Click] heap MB: 55
[@Click] heap MB: 55
[@Click] heap MB: 55
[@Click] heap MB: 59
[@Click] heap MB: 59
Navigate IWE and settings Verify IWE and settings
Navigate to Homepage Verify that the page has navigated to Homepage
<<<Scroll>> <<<End>>
[@Displayed] heap MB: 55
[@Click] heap MB: 58
[@Click] heap MB: 62
[@Click] heap MB: 62
[@Click] heap MB: 68
[@Click] heap MB: 67
[@Click] heap MB: 67
[@Click] heap MB: 71
[@Click] heap MB: 69
[@Click] heap MB: 69
[@Click] heap MB: 75
[@Click] heap MB: 71
[@Click] heap MB: 71
[@Click] heap MB: 76
[@Click] heap MB: 74
[@Click] heap MB: 74
[@Click] heap MB: 84
[@Click] heap MB: 78
[@Click] heap MB: 78
[@Click] heap MB: 84
[@Click] heap MB: 82
[@Click] heap MB: 82
[@Click] heap MB: 86

Kindly please check from your side in Windows 32 Bit OS and let me know whether 
this issue has been resolved.

Thanks
Saranya

Original comment by saranyab...@gmail.com on 19 Jun 2013 at 12:48