Re: Memory leaking

andresgr <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
I found the leak!

This Netbeans profiler tool is really amazing :)

Well, the fact: the memory was allocated by

private void handleScriptException( Exception e, String badScript )

in com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine

and I discovered that HttpUnit stores *all* JavaScript Exceptions in a
private buffer, which *you* have to clear manually from time to time,
if you don't want to loose your memory along the way :)

The "buffer":

private static ArrayList _errorMessages = new ArrayList();

You can clear that buffer calling:

HttpUnitOptions.clearScriptErrorMessages();

I think this "feature" should be disabled by default or... i don't
know, use a buffer of limited size...

Cheers.

2006/12/18, Morgan Christiansson <[email protected]>:
> Perhaps you're keeping references to the original String's containing
> the whole 500kb of returned data from the webserver.
>
> This would be caused by for example String.substring() which doesn't
> create a new string but only references part of the original string, try
> calling new String() on strings you keep to ensure that you're not
> keeping old data in memory by accident.
>
> For more info look at this  google search:
> http://www.google.co.uk/search?hl=en&safe=off&q=java+string+memory+leak
> +substring&btnG=Search&meta=
>
> Although it could very well be something else. But String leaks in this
> way is quite common, esp. as you deal with a lot of String's.
>
> Regards,
> Morgan
>
> On Mon, 2006-12-18 at 10:29 +0100, andresgr wrote:
> > I'm trying to profile it, but the app hangs most of the time when i
> > try to take a snapshot (Nebeans 5.5 + Profiler).
> >
> > So I don't know if it is httpunit or my code....
> >
> > 2006/12/16, James Abley < [email protected]>:
> >         I haven't seen this myself. Have you profiled the application
> >         to see
> >         what's leaking?
> >
> >         On 12/12/06, andresgr <[email protected]> wrote:
> >         > Hi.
> >         >
> >         > Has anybody experienced memory leaking problems with
> >         httpUnit? I have
> >         > problems when i run long tests (one or two days) and big
> >         pages (500K
> >         > or so).
> >         >
> >         > I use WebResponse.getText() method for each page, which
> >         creates
> >         > temporal buffers, strings etc.
> >         >
> >         > Anyone had similar problems?
> >         >
> >         > Regards.
> >         >
> >         > --
> >         > -=-=-=-=-=-=-=-=-=-=-=-=-
> >         > Andrés González.
> >         > http://coyotevil.blogspot.com
> >         >
> >         >
> >         -------------------------------------------------------------------------
> >         > Take Surveys. Earn Cash. Influence the Future of IT
> >         > Join SourceForge.net's Techsay panel and you'll get the
> >         chance to share your
> >         > opinions on IT & business topics through brief surveys - and
> >         earn cash
> >         >
> >         http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> >         > _______________________________________________
> >         > Httpunit-develop mailing list
> >         > [email protected]
> >         >
> >         https://lists.sourceforge.net/lists/listinfo/httpunit-develop
> >         >
> >
> >         -------------------------------------------------------------------------
> >         Take Surveys. Earn Cash. Influence the Future of IT
> >         Join SourceForge.net 's Techsay panel and you'll get the
> >         chance to share your
> >         opinions on IT & business topics through brief surveys - and
> >         earn cash
> >         http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> >         _______________________________________________
> >         Httpunit-develop mailing list
> >         [email protected]
> >         https://lists.sourceforge.net/lists/listinfo/httpunit-develop
> >
> >
> >
> > --
> > -=-=-=-=-=-=-=-=-=-=-=-=-
> > Andrés González.
> > http://coyotevil.blogspot.com
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>


-- 
-=-=-=-=-=-=-=-=-=-=-=-=-
Andrés González.
http://coyotevil.blogspot.com

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.