You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Toby Lazar <tl...@capitaltg.com> on 2014/03/03 22:21:15 UTC
closing hbase resources for webapp
I am working on an HBase webapp and Tomcat is telling me I have a memory
leak, which I have confirmed, but I'm not sure how to fix it. I've reduced
my app to a single jsp that calls a single method (both are included below
since they are short). After I reload my application, Tomcat detects that
I may have a memory leak, leading me to think I should be doing something
else when closing an HConnection. I tried the deprecated
HConnectionManager.deleteConnection(config) without any luck.
I am using Hadoop 2.2/HBase 0.96 client jars and running it on Tomcat
7.0.47/JVM 1.7.0_45 on CentOS 6.5.
Any ideas what I'm missing or how to work around this?
Thanks!
Toby
JSP is:
<%@page import="foobar.Test"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%out.println(Test.hello()); %>
Java method in the Test class is:
public static String hello() throws IOException{
Configuration config = HBaseConfiguration.create();
HConnection connection = HConnectionManager.createConnection(config);
HTableInterface table = connection.getTable("sometable");
table.close();
connection.close();
return "hellosay";
}
*******************************
Toby Lazar
Capital Technology Group
Email: tlazar@capitaltg.com
Mobile: 646-469-5865
*******************************
Re: closing hbase resources for webapp
Posted by Toby Lazar <tl...@capitaltg.com>.
After hitting the jsp once and then reloading the app, I ran Find leaks
through the manager application at http://localhost:8080/manager/html and
get this:
The following web applications were stopped (reloaded, undeployed), but their
classes from previous runs are still loaded in memory, thus causing a memory
leak (use a profiler to confirm):
/dynam
The name of the web app context is dynam. Each time I repeat, I get
an extra /dynam line, as expected. Additionally, each time I reload
the context catalina.out shows:
SEVERE: The web application [/dynam] appears to have started a thread
named
[IPC Client (1622444498) connection to hb02/192.168.200.102:60020 from
tslazar]
but has failed to stop it. This is very likely to create a memory leak.
Is there a ZooKeeper method I should call to shutdown a thread? I added a
finally block though that doesn't change the behavior.
On Mon, Mar 3, 2014 at 8:55 PM, Ted Yu <yu...@gmail.com> wrote:
> bq. Tomcat detects that I may have a memory leak
>
> Can you show us the warning from Tomcat.
>
> w.r.t. the snippet you posted: the two close() calls should be enclosed in
> finally block.
>
>
> On Mon, Mar 3, 2014 at 1:21 PM, Toby Lazar <tl...@capitaltg.com> wrote:
>
> > I am working on an HBase webapp and Tomcat is telling me I have a memory
> > leak, which I have confirmed, but I'm not sure how to fix it. I've
> reduced
> > my app to a single jsp that calls a single method (both are included
> below
> > since they are short). After I reload my application, Tomcat detects
> that
> > I may have a memory leak, leading me to think I should be doing something
> > else when closing an HConnection. I tried the deprecated
> > HConnectionManager.deleteConnection(config) without any luck.
> >
> > I am using Hadoop 2.2/HBase 0.96 client jars and running it on Tomcat
> > 7.0.47/JVM 1.7.0_45 on CentOS 6.5.
> >
> > Any ideas what I'm missing or how to work around this?
> >
> > Thanks!
> >
> > Toby
> >
> >
> >
> > JSP is:
> >
> > <%@page import="foobar.Test"%>
> > <%@ page language="java" contentType="text/html; charset=UTF-8"
> > pageEncoding="UTF-8"%>
> > <%out.println(Test.hello()); %>
> >
> > Java method in the Test class is:
> >
> > public static String hello() throws IOException{
> > Configuration config = HBaseConfiguration.create();
> > HConnection connection = HConnectionManager.createConnection(config);
> > HTableInterface table = connection.getTable("sometable");
> > table.close();
> > connection.close();
> > return "hellosay";
> > }
> >
> >
> >
> > *******************************
> > Toby Lazar
> > Capital Technology Group
> > Email: tlazar@capitaltg.com
> > Mobile: 646-469-5865
> > *******************************
> >
>
Re: closing hbase resources for webapp
Posted by Ted Yu <yu...@gmail.com>.
bq. Tomcat detects that I may have a memory leak
Can you show us the warning from Tomcat.
w.r.t. the snippet you posted: the two close() calls should be enclosed in
finally block.
On Mon, Mar 3, 2014 at 1:21 PM, Toby Lazar <tl...@capitaltg.com> wrote:
> I am working on an HBase webapp and Tomcat is telling me I have a memory
> leak, which I have confirmed, but I'm not sure how to fix it. I've reduced
> my app to a single jsp that calls a single method (both are included below
> since they are short). After I reload my application, Tomcat detects that
> I may have a memory leak, leading me to think I should be doing something
> else when closing an HConnection. I tried the deprecated
> HConnectionManager.deleteConnection(config) without any luck.
>
> I am using Hadoop 2.2/HBase 0.96 client jars and running it on Tomcat
> 7.0.47/JVM 1.7.0_45 on CentOS 6.5.
>
> Any ideas what I'm missing or how to work around this?
>
> Thanks!
>
> Toby
>
>
>
> JSP is:
>
> <%@page import="foobar.Test"%>
> <%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>
> <%out.println(Test.hello()); %>
>
> Java method in the Test class is:
>
> public static String hello() throws IOException{
> Configuration config = HBaseConfiguration.create();
> HConnection connection = HConnectionManager.createConnection(config);
> HTableInterface table = connection.getTable("sometable");
> table.close();
> connection.close();
> return "hellosay";
> }
>
>
>
> *******************************
> Toby Lazar
> Capital Technology Group
> Email: tlazar@capitaltg.com
> Mobile: 646-469-5865
> *******************************
>