OutOfMemory and im==null error during snapAll()

39 views
Skip to first unread message

Michael Pyle

unread,
Feb 7, 2011, 4:25:01 PM2/7/11
to watij
Hi, whenever I attempt to use snapAll() on a page that is very long
(it normally is quite short, but every now and again if there's an
error with the page it will display a massive stack trace, making the
page quite long), I receive an OutOfMemoryError which I assume occurs
when JxBrowser attempts to take the screen shot, and then the JVM will
crash with this exception during ImageIO.write:

Exception in thread "Main message loop" java.lang.OutOfMemoryError:
Java heap space
java.lang.IllegalArgumentException: im == null!
at javax.imageio.ImageIO.write(Unknown Source)
at javax.imageio.ImageIO.write(Unknown Source)
at org.watij.webspec.dsl.WebSpec.snap(WebSpec.java:468)
at org.watij.webspec.dsl.WebSpec.snapAll(WebSpec.java:462)
at
au.gov.centrelink.qa.jnat.web.NWebEntity.takeScreenShot(NWebEntity.java:
225)
at
au.gov.centrelink.qa.jnat.web.NWebExecutionContext.takeScreenShot(NWebExecutionContext.java:
88)
at
au.gov.centrelink.qa.jnat.NUtils.createScreenShot(NUtils.java:350)
at au.gov.centrelink.qa.jnat.NUtils.sendResult(NUtils.java:
390)
at
au.gov.centrelink.qa.jnat.functional.NResultAction.execute(NResultAction.java:
30)
at
au.gov.centrelink.qa.jnat.execution.NExecutor.execute(NExecutor.java:
380)
at
au.gov.centrelink.qa.jnat.execution.NExecutionThread.run(NExecutionThread.java:
21)
at java.lang.Thread.run(Unknown Source)

Would it be possible to add a 'null' check during that part of the
code that calls ImageIO - to not call ImageIO if the image returned
from JxBrowser is null?
And even better would also be some kind of getContentSize() method for
the browser so I can call snap() instead of snapAll() if the displayed
content is too large.

Thanks for your time.

Brian Knorr

unread,
Feb 7, 2011, 5:11:30 PM2/7/11
to watij
Sure I can add the null check....also to get the content height you
could always use javascript by calling WebSpec.execute

Michael Pyle

unread,
Feb 9, 2011, 1:53:12 AM2/9/11
to watij
Thanks!
Reply all
Reply to author
Forward
0 new messages