i made some changes to the code. (posted one jsp at the end of this mail)

. change was, to avoid to store values in the session and keeped the values as 
hiddens in forms.

looks like it worked. But

. yes, connections are closed, im requesting a connection from the datasource 
and after use it i close the Statement, the ResultSet and the Connection on 
every jsp.

. im kind a newbie, how can i look into the memory leak?


To devel , i run on my laptop (a macbook pro) a local postgres, this postgres 
has a 5 non-superuser connection limit, but i never had problems with that part 
since im the only user testing. At first i thought that the database was 
imposing limits, but i had no logs at all in the database (i have it with logs 
at debug level). And moving my application to a production server (with 200 
connections available) has the same problem (after a while i get a memory heap 
full message which is logic on this situation i think)

Here's one of the jsp's (all the 3 are the same, the only thing that changes 
are the db tables where the queries are executed)

--

<%-- 
    Document   : displayTime
    Created on : Feb 13, 2011, 5:27:00 PM
    Author     : alz
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.sql.DataSource"%>
<%@page import="java.util.Enumeration"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd";>

<%
            /*
            Enumeration e = request.getParameterNames();
            while (e.hasMoreElements()) {
            String parameter = (String) e.nextElement();
            out.println(parameter + ":" + request.getParameter(parameter));
            }
            }
             */
            java.sql.Connection c1;
            java.sql.Statement s1;
            java.sql.ResultSet rs1;

            c1 = null;
            s1 = null;
            rs1 = null;

            DataSource ds = (DataSource) new 
InitialContext().lookup("java:/comp/env/jdbc/postgres");
            c1 = ds.getConnection();
            s1 = c1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, 
ResultSet.CONCUR_UPDATABLE);

            String query = "select distinct(name) from list.vdn where 
meas='int' order by name";
            rs1 = s1.executeQuery(query);

%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/lcms3.css" rel="stylesheet" type="text/css" />
    </head>
    <body class="bodyframeless">

        <%
                    if (request.getParameter("vdnFecha") == null) {
        %>
        <table>
            <tr><td><form name="agentForm" action="<% 
request.getRequestURI();%>" method="POST">
                        <select name="vdn" size="7" >

                            <%
                                                    while (rs1.next()) {
                            %>
                            <option value="<%= rs1.getString("name")%>"><%= 
rs1.getString("name")%></option>
                            <%
                                                    }
                            %>

                        </select><br>
                        <input type="submit" name="c_vdn" value="vdn">
                    </form>
                </td>
                <td>
                    <form name="dateForm" action="<% 
request.getRequestURI();%>" method="POST">
                        <%
                                                if (request.getParameter("vdn") 
!= null) {
                                                    out.println("<input 
type=\"hidden\" name=\"vdn\" value=\"" + request.getParameter("vdn") + "\">");
                                                }
                        %>
                        <select name="vdnFecha" size="7">
                            <%
                                                    if 
(request.getParameter("vdn") != null) {
                                                        rs1 = 
s1.executeQuery("select distinct(measdate) from list.bcmsvdn where vdnname='" + 
request.getParameter("vdn") + "' order by measdate desc");
                                                        while (rs1.next()) {
                            %>
                            <option value="<%= rs1.getString("measdate")%>"><%= 
 rs1.getString("measdate")%></option>
                            <%
                                                        }
                                                    }
                            %>
                        </select>
                        <br>
                        <input type="submit" name="c_measdate" value="fecha">
                    </form>
                </td></tr></table>
                <%
                                    } else {
                                        //mostrar resultados y poner link de 
reset
                                        out.println("<a href=\"" + 
request.getRequestURI() + "\">Seleccionar otro agente</a>");

                %>
        <table>
            <tr>
                <th>ID</th>
                <th>Nombre</th>
                <th>servlevel</th>
                <th>Inicio</th>
                <th>Fin</th>
                <th>Ofrec</th>
                <th>ACD</th>
                <th>P aten</th>
                <th>aband</th>
                <th>P aband</th>
                <th>P conv/hold</th>
                <th>Conn</th>
                <th>flowout</th>
                <th>Oc/desc</th>
                <th>inserv</th>
            </tr>
            <%
                                    rs1 = s1.executeQuery("select * from 
list.bcmsvdn where vdnname='" + request.getParameter("vdn") + "' and 
measdate='" + request.getParameter("vdnFecha") + "'");
                                    while (rs1.next()) {
            %>
            <tr>
                <td><%= rs1.getString("vdn")%></td>
                <td><%= rs1.getString("vdnname")%></td>
                <td><%= rs1.getInt("acceptableservicelevel")%></td>
                <%
                                                        if 
(rs1.getString("day").equals("1955-10-17")) {
                                                            out.println("<td>" 
+ rs1.getString("starttime") + "</td>");
                                                            out.println("<td>" 
+ rs1.getString("stoptime") + "</td>");
                                                        } else {
                                                            out.println("<td>" 
+ rs1.getString("day") + "</td>");
                                                            
out.println("<td></td>");
                                                        }
                %>
                <td><%= rs1.getInt("callsoffered")%></td>
                <td><%= rs1.getInt("acdcalls")%></td>
                <td><%= rs1.getInt("avgspeedans")%></td>
                <td><%= rs1.getInt("abandcalls")%></td>
                <td><%= rs1.getInt("avgabandtime")%></td>
                <td><%= rs1.getInt("avgtalkhold")%></td>
                <td><%= rs1.getInt("conncalls")%></td>
                <td><%= rs1.getInt("flowout")%></td>
                <td><%= rs1.getInt("callsbusydisc")%></td>
                <td><%= rs1.getInt("inservlevel")%></td>
            </tr>

            <%
                            }
                        }
            %>
        </table>
    </body>
</html>

<%

            rs1.close();
            s1.close();
            c1.close();

%>

--

On Mar 21, 2011, at 11:40 AM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Alexis,
> 
> On 3/21/2011 8:17 AM, alexis wrote:
>> Problem is, after 2 or 3 reloads or moving from one jsp to another
>> one, pages are not loaded anymore, browser keeps loading for ever.
> 
> Take some thread dumps. I suspect that you are waiting for a database
> connection to become available. Are you calling Connection.close() in a
> finally block in your JSP? Or are you using a tab library that handles
> all that complexity for you?
> 
>> If a redeploy the app I get a memory leak.
> 
> :(
> 
> Have you looked into that?
> 
>> Using a profiler the http-8080 threads are the one that looks that
>> enters to wait.
> 
> Of course they are: there's virtually nothing else running. The question
> is *where* are they entering a wait?
> 
>> Any help will be really helpful.
> 
> Can you post some or all of your JSP?
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk2HY0wACgkQ9CaO5/Lv0PCXRQCfQbrohH6wQ+Sa5QZvasyvO2MI
> Ev4An2IOdFF1NSmbNDzr7hS6a/f7XY60
> =uwMs
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to