Howdy,
A Profiler is your friend.  My favorite is OptimizeIt.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Shaun Roach [mailto:[EMAIL PROTECTED]
>Sent: Thursday, February 27, 2003 6:36 PM
>To: [EMAIL PROTECTED]
>Subject: Beginner problems with Tomcat and Memory
>
>Hi, I am using Tomcat for just the second time, and I am running into
>some trouble.
>
>I am trying to make a fantasy baseball drafting webpage for me and my
>friends.  The code below is a servlet action class that will execute
>properly (and produce the proper jsp) for the first two times it is
>called.
>
>However, invariably on the third execution, the memory balloons out of
>control (I know this isn't very accurate, but I am looking at my task
>manager Mem usage column)  it goes from about 30MB when the application
>first runs to around 300MB or more, until my whole system crashes when
>the code is run for the third time.
>
>I am using Windows 2000, j2sdk1.4.1_01 and Tomcat 4.0.
>
>Here is my code.  I browsed the archives and haven't found any examples
>for memory leaks that happen this drastically.  I hope someone can
help,
>I would be very appreciative.  Here is my code
>
>Thanks,
>Shaun Roach
>
>
>public final class DraftAction extends Action {
>
>
>
>    public ActionForward perform(ActionMapping mapping,
>                                ActionForm form,
>                                HttpServletRequest request,
>                                HttpServletResponse response)
>       throws IOException, ServletException {
>
>       // Extract attributes we will need
>       Locale locale = getLocale(request);
>
>       // Validate the request parameters specified by the user
>       ActionErrors errors = new ActionErrors();
>       HttpSession session = request.getSession();
>
>
>
>       String position = request.getParameter("position");
>       String ix = request.getParameter("ix");
>       ArrayList teams = (ArrayList)session.getAttribute("teams");
>       ArrayList positions =
>(ArrayList)session.getAttribute("positionLists");
>       Team draftingTeam = (Team)teams.get(0);
>
>       PositionList positionList;
>       PositionList teamPositionList;
>       if( "C".equals(position) ) {
>               positionList = (PositionList)positions.get(0);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(0);
>       }
>       else if( "1B".equals(position) ) {
>               positionList = (PositionList)positions.get(1);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(1);
>       }
>       else if( "2B".equals(position) ) {
>               positionList = (PositionList)positions.get(2);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(2);
>       }
>       else if( "3B".equals(position) ) {
>               positionList = (PositionList)positions.get(3);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(3);
>       }
>       else if( "SS".equals(position) ) {
>               positionList = (PositionList)positions.get(4);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(4);
>       }
>       else  {
>               positionList = (PositionList)positions.get(5);
>               teamPositionList =
>(PositionList)draftingTeam.getPositions().get(5);
>       }
>
>
>       int index;
>       try
>       {
>               index = Integer.parseInt(ix);
>       }
>       catch(NumberFormatException nfe)
>       {
>               index = 0;
>       }
>
>
>       if( index >= positionList.getPlayers().size() )
>               index = 0;
>
>       Player player = (Player)positionList.getPlayers().get(index);
>       positionList.getPlayers().remove(index);
>       teamPositionList.getPlayers().add(player);
>
>
>
>       // Report any errors we have discovered back to the original
>form
>       if (!errors.empty()) {
>           saveErrors(request, errors);
>           return (new ActionForward(mapping.getInput()));
>       }
>
>
>
>       session.setAttribute("positionLists",positions);
>       session.setAttribute("teams", teams);
>
>
>
>/*
>
>*/
>
>       // Forward control to the specified success URI
>
>
>       // Remove the obsolete form bean
>       if (mapping.getAttribute() != null) {
>       if ("request".equals(mapping.getScope()))
>               request.removeAttribute(mapping.getAttribute());
>        else
>            session.removeAttribute(mapping.getAttribute());
>    }
>       return (mapping.findForward("draftpage"));
>    }
>}
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to