[Java] Mac: Eclipse: Java Heap Error --- adjustments in build.xml needed

Asked by Jeremiah Jacquet

*** Solution:
Remember to add maxmemory="2048m" wherever necessary in your targets to increase heap size in your ant build file. Obviously the number 2048 can get bigger if you want more memory allocated to your target.

------------------------------------------------------------------------------------------------------
Hey Sikuli devs,

 first off thanks for making such a great product.

I am experiencing a Java heap error when running my tests. Here is my scenario

Mac OSX 10.6.6
Eclipse
Ant (latest)
Fest (latest)
Jenkins
tests written in Java using your libraries (latest)
java version "1.6.0_22"

in my build xml i set the maxmemory as follows:

 <junit forkmode="perTest" printsummary="yes" haltonfailure="no" haltonerror="no" maxmemory="2048m">

The test begins and almost finishes, at the end of the test my build fails with this error:
Java heap space

java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.(BufferedImage.java:324)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:539)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:523)
at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:191)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3261)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3246)

at org.sikuli.script.OpenCV.convertBufferedImageToByteArray(OpenCV.java:30)
at org.sikuli.script.OpenCV.convertBufferedImageToMat(OpenCV.java:36)
at org.sikuli.script.Finder.(Finder.java:56)
at org.sikuli.script.Region.doFind(Region.java:769)
at org.sikuli.script.Region$RepeatableFind.run(Region.java:1160)
at org.sikuli.script.Region$Repeatable.repeat(Region.java:1131)
at org.sikuli.script.Region.wait(Region.java:406)
at org.sikuli.script.Region.find(Region.java:308)
at org.sikuli.script.Region.getLocationFromPSRML(Region.java:856)
at org.sikuli.script.Region.click(Region.java:488)
at com.eharmony.iphoneautomation.tests.TestNewMemberScreenInput.testFindMyMatches(Unknown Source)

on the mac I am using its 64bit so i know i can set the memory higher for JVM. Is there something in sikuli I can set

thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #748036.

Revision history for this message
Jeremiah Jacquet (jeremiahjacquet) said :
#1

Hi Tom,

 here is my high level of my scripts being run

in my setup script i am making calls to github which means checkout times
can vary within the terminal so I have thinktime next to the wait method
from sikuli.

here is an example of that:

                    s.type(null, gitCommand, 0);

                    thinktime(50000);

                    s.wait(Images.TERMINAL_GITCHECKOUTCOMPLETE_TEXT, 500);

                    thinktime(3000);

                    s.type(null, "cd " + absolutePathOfSinglesIphoneDir + "
\r", 0);

                    thinktime(2000);

                    s.type(null, "git submodule init \r", 0);

                    thinktime(2000);

                    s.wait(Images.TERMINAL_GITINITCOMPLETE_TEXT, 500);

                    thinktime(2000);

                    s.type(null, "git submodule update \r", 0);

                    thinktime(50000);

                    s.wait(Images.TERMINAL_GITUPDATECOMPLETE_TEXT, 500);

                    thinktime(2000);

                    s.type(null, "cd " + absolutePathOfSinglesIphoneDir + "
\r", 0);

Following the setup method I run some find method from Sikuli inconjunction
with another library called robot and run test like this:

@Test

public void testFemaleGenderPositiveEntry() throws Exception {

 String result = "";

 MobileUtils.thinktime(THINKTIME);

 s.find("imgs/EharmonyHeader.png");

 robot.mouseMove((s.getLastMatch().below().getX() + 235), (s

.getLastMatch().below().getY() + 120));

 MobileUtils.thinktime(THINKTIME);

 robot.mousePress(InputEvent.BUTTON1_MASK);

robot.mouseRelease(InputEvent.BUTTON1_MASK);

 MobileUtils.thinktime(THINKTIME);

 if (s.find("imgs/GenderFemaleEnabled.png") != null) {

result = "true";

}

 assertTrue(

"The gender selector should be set to Woman defined in a pink selection.",

result.contains("true"));

 } // end method

There are 20 more test almost like this one that continue to run before the
crash occurs. Something I should mention here I have not had this problem in
the past with your previous version of sikuli.

The images are 2-4k pngs, and I will have to get back to you on objects size
before garbage collection.

thanks,
JJacquet

On Sat, Apr 2, 2011 at 5:04 AM, Tom Yeh <email address hidden> wrote:

> Hi,
>
> Thanks for reporting this memory leak error. It's not immediately
> obvious where the error comes from. Can you provide more information,
> like the kind of operations performed by your test scripts,
> resolutions of images being tested, and how fast the memory
> consumption seems to grow? Thanks!
>
> Tom
>
>
> On Sat, Apr 2, 2011 at 1:57 AM, Jeremiah Jacquet
> <email address hidden> wrote:
> > Public bug reported:
> >
> > Hey Sikuli devs,
> >
> > first off thanks for making such a great product.
> >
> > I am experiencing a Java heap error when running my tests. Here is my
> > scenario
> >
> > Mac OSX 10.6.6
> > Eclipse
> > Ant (latest)
> > Fest (latest)
> > Jenkins
> > tests written in Java using your libraries (latest)
> > java version "1.6.0_22"
> >
> > in my build xml i set the maxmemory as follows:
> >
> > <junit forkmode="perTest" printsummary="yes" haltonfailure="no"
> > haltonerror="no" maxmemory="2048m">
> >
> > The test begins and almost finishes, at the end of the test my build
> fails with this error:
> > Java heap space
> >
> > java.lang.OutOfMemoryError: Java heap space
> > at java.awt.image.DataBufferInt.(DataBufferInt.java:41)
> > at java.awt.image.Raster.createPackedRaster(Raster.java:458)
> > at
> java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
> > at java.awt.image.BufferedImage.(BufferedImage.java:324)
> > at
> sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:539)
> > at
> sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:523)
> > at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:191)
> > at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
> > at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
> > at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
> > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
> > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
> > at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
> > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3261)
> > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3246)
> >
> > at
> org.sikuli.script.OpenCV.convertBufferedImageToByteArray(OpenCV.java:30)
> > at org.sikuli.script.OpenCV.convertBufferedImageToMat(OpenCV.java:36)
> > at org.sikuli.script.Finder.(Finder.java:56)
> > at org.sikuli.script.Region.doFind(Region.java:769)
> > at org.sikuli.script.Region$RepeatableFind.run(Region.java:1160)
> > at org.sikuli.script.Region$Repeatable.repeat(Region.java:1131)
> > at org.sikuli.script.Region.wait(Region.java:406)
> > at org.sikuli.script.Region.find(Region.java:308)
> > at org.sikuli.script.Region.getLocationFromPSRML(Region.java:856)
> > at org.sikuli.script.Region.click(Region.java:488)
> > at
> com.eharmony.iphoneautomation.tests.TestNewMemberScreenInput.testFindMyMatches(Unknown
> Source)
> >
> >
> > on the mac I am using its 64bit so i know i can set the memory higher for
> JVM. Is there something in sikuli I can set
> >
> >
> > thanks
> >
> > ** Affects: sikuli
> > Importance: Undecided
> > Status: New
> >
> > --
> > You received this bug notification because you are a member of Sikuli
> > Drivers, which is subscribed to Sikuli.
> > https://bugs.launchpad.net/bugs/748036
> >
> > Title:
> > JVM OOM Java Heap Error on Mac OSX 10.6.6
> >
> > Status in Sikuli:
> > New
> >
> > Bug description:
> > Hey Sikuli devs,
> >
> > first off thanks for making such a great product.
> >
> > I am experiencing a Java heap error when running my tests. Here is my
> > scenario
> >
> > Mac OSX 10.6.6
> > Eclipse
> > Ant (latest)
> > Fest (latest)
> > Jenkins
> > tests written in Java using your libraries (latest)
> > java version "1.6.0_22"
> >
> > in my build xml i set the maxmemory as follows:
> >
> > <junit forkmode="perTest" printsummary="yes" haltonfailure="no"
> > haltonerror="no" maxmemory="2048m">
> >
> > The test begins and almost finishes, at the end of the test my build
> fails with this error:
> > Java heap space
> >
> > java.lang.OutOfMemoryError: Java heap space
> > at java.awt.image.DataBufferInt.(DataBufferInt.java:41)
> > at java.awt.image.Raster.createPackedRaster(Raster.java:458)
> > at
> java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
> > at java.awt.image.BufferedImage.(BufferedImage.java:324)
> > at
> sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:539)
> > at
> sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:523)
> > at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:191)
> > at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:186)
> > at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
> > at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
> > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:54)
> > at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:982)
> > at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:168)
> > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3261)
> > at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3246)
> >
> > at
> org.sikuli.script.OpenCV.convertBufferedImageToByteArray(OpenCV.java:30)
> > at org.sikuli.script.OpenCV.convertBufferedImageToMat(OpenCV.java:36)
> > at org.sikuli.script.Finder.(Finder.java:56)
> > at org.sikuli.script.Region.doFind(Region.java:769)
> > at org.sikuli.script.Region$RepeatableFind.run(Region.java:1160)
> > at org.sikuli.script.Region$Repeatable.repeat(Region.java:1131)
> > at org.sikuli.script.Region.wait(Region.java:406)
> > at org.sikuli.script.Region.find(Region.java:308)
> > at org.sikuli.script.Region.getLocationFromPSRML(Region.java:856)
> > at org.sikuli.script.Region.click(Region.java:488)
> > at
> com.eharmony.iphoneautomation.tests.TestNewMemberScreenInput.testFindMyMatches(Unknown
> Source)
> >
> >
> > on the mac I am using its 64bit so i know i can set the memory higher
> for JVM. Is there something in sikuli I can set
> >
> >
> > thanks
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~sikuli-driver
> > Post to : <email address hidden>
> > Unsubscribe : https://launchpad.net/~sikuli-driver
> > More help : https://help.launchpad.net/ListHelp
> >
>

Revision history for this message
Jeremiah Jacquet (jeremiahjacquet) said :
#2

OK worries are gone!

It turns out to be the build.xml

The maxmemory for the build xml in runAll targets was not set causing the test to blow up. However, the maxmemory enhancement in the build.xml was necessary due to java errors when using sikuli. I increased the .plist file and forkmode adjustments in the xml. The problem is now gone.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

Turned out to not to be Sikuli bug - but information seems valuable

Revision history for this message
RaiMan (raimund-hocke) said :
#4

solved by user himself

Revision history for this message
Raymond Gonzales (atlas1015) said :
#5

the .plist file modification was not necessary to be clear. the issue for Jeremiah was that the target he was calling did not have the maxmemory="2048m" in his junit node of his target.....once he added that, he was good to go :) Remember to add maxmemory="2048m" wherever necessary in your targets to increase heap size in your ant build file. Obviously the number 2048 can get bigger if you want more memory allocated to your target.