From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43162 invoked by alias); 15 Jan 2016 18:41:30 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 43134 invoked by uid 89); 15 Jan 2016 18:41:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:context, UD:add, 115,8, 1158 X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 15 Jan 2016 18:41:26 +0000 Received: from [10.9.9.206] (helo=mailfront02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1aK9JJ-0005SF-F0; Fri, 15 Jan 2016 19:41:21 +0100 Received: from 70-36-239-75.dsl.dynamic.fusionbroadband.com ([70.36.239.75] helo=toshie.bothner.com) by mailfront02.runbox.com with esmtpsa (uid:757155 ) (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) id 1aK9J2-0007MF-3i; Fri, 15 Jan 2016 19:41:04 +0100 Subject: Re: kawa and apache tomcat To: Matthieu Vachon , Damien MATTEI References: <201601151145.23595.Damien.Mattei@unice.fr> Cc: "kawa@sourceware.org" From: Per Bothner Message-ID: <56993D3C.20105@bothner.com> Date: Fri, 15 Jan 2016 18:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------050609080504040604090703" X-IsSubscribed: yes X-SW-Source: 2016-q1/txt/msg00003.txt.bz2 This is a multi-part message in MIME format. --------------050609080504040604090703 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1106 On 01/15/2016 10:10 AM, Matthieu Vachon wrote: > This is not a problem in a standard JVM application because once the > application closes, nothing needs to be done. But in a container > environment, that's another story since thread a kinda re-used over > multiple requests. On high load, this can create huge memory leaks > depending on the what is actually stored. As I understand it, the problem is not normal usage, but when a servlet is re-loaded. That creates a new ClassLoader, with a new set of Classes which causes some complicated interaction with the GC (which I don't properly understand). In normal usage,with no ClassLoader churn, there might be some temporary leak, but the garbage should become collectible when a thread services a new request. Could you try the attached patch? I haven't actually tested it (except to verify it compiles). Let me know if it makes a difference. It is possible it might *reduce* the number but not eliminate the warnings. If so, we would be on the right track, though with more to do. -- --Per Bothner per@bothner.com http://per.bothner.com/ --------------050609080504040604090703 Content-Type: text/x-patch; name="servet.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="servet.patch" Content-length: 1849 Index: gnu/kawa/servlet/KawaServlet.java =================================================================== --- gnu/kawa/servlet/KawaServlet.java (revision 8666) +++ gnu/kawa/servlet/KawaServlet.java (working copy) @@ -41,17 +41,9 @@ throws ServletException, IOException { CallContext ctx = CallContext.getInstance(); - HttpRequestContext hctx = HttpRequestContext.instance.get(); - Context sctx; - if (hctx instanceof Context) - sctx = (Context) hctx; - else - { - sctx = new Context(); - Context.setInstance(sctx); - } - sctx.init(this, request, response); + Context sctx = new Context(this, request, response); ctx.consumer = sctx.getConsumer(); + Context.setInstance(sctx); // FIXME should path be relative to context? Path.setCurrentPath(Path.valueOf(request.getRequestURL().toString())); ctx.values = Values.noArgs; @@ -100,6 +92,7 @@ } finally { + Context.setInstance(null); sctx.servlet = null; sctx.request = null; sctx.response = null; @@ -115,8 +108,8 @@ ServletContext context; Map requestParameters; - public void init(HttpServlet servlet, HttpServletRequest request, - HttpServletResponse response) + public Context(HttpServlet servlet, HttpServletRequest request, + HttpServletResponse response) { if (response == null) throw new Error("init with null response"); @@ -317,7 +310,7 @@ public List getRequestHeaders (String name) { java.util.Enumeration e = request.getHeaders(name); - List list = new ArrayList(); + List list = new ArrayList(); while (e.hasMoreElements()) { list.add(e.nextElement()); --------------050609080504040604090703--