[jboss-jira] [JBoss JIRA] (WFLY-5731) PollSelectorImpl's FD leak for asyncServlet

Stuart Douglas (JIRA) issues at jboss.org
Wed Nov 25 22:58:00 EST 2015


    [ https://issues.jboss.org/browse/WFLY-5731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13134006#comment-13134006 ] 

Stuart Douglas commented on WFLY-5731:
--------------------------------------

This XNIO commit may fix the problem: https://github.com/xnio/xnio/compare/3.x...stuartwdouglas:finalize?expand=1

Unfortunately if you create and destroy a lot of threads very quickly it may be that GC cannot keep up and you will run out of FD's anyway. You are much better off using some kind of thread pool, as it will perform much better anyway.

> PollSelectorImpl's FD leak for asyncServlet
> -------------------------------------------
>
>                 Key: WFLY-5731
>                 URL: https://issues.jboss.org/browse/WFLY-5731
>             Project: WildFly
>          Issue Type: Bug
>          Components: Web (Undertow)
>    Affects Versions: 8.1.0.Final
>         Environment: OS:Red Hat Enterprise Linux Server release 5.5 (Tikanga) 
> MW:wildfly-8.1.0.Final
> JDK:
> java version "1.7.0_25"
> Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
> Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
>            Reporter: 浩 陈
>            Assignee: Stuart Douglas
>            Priority: Critical
>         Attachments: DemoServlet.java
>
>
> AsyncServlet doGet() like this: 
>     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws     ServletException, IOException {
> 		resp.setContentType("text/html;charset=UTF-8");
> 		AsyncContext ctx = req.startAsync();
> 		new Thread(new Executor(ctx)).start();
> 	}
> public class Executor implements Runnable {
> 		private AsyncContext ctx = null;
> 		public Executor(AsyncContext ctx) {
> 			this.ctx = ctx;
> 		}
> 		public void run() {
> 			try {
> 				char[] data = new char[1024 * 1024 * 1];
> 				PrintWriter out = ctx.getResponse().getWriter();
> 				out.write(data);
> 				out.flush();
> 				ctx.complete();
> 			} catch (Exception e) {
> 				e.printStackTrace();
> 			}
> 		}
> do request this Servlet some times , run linux cmd :
> lsof -p [JAVAPID]|grep pipe|wc -l
> this number increases by two every one request,but never decrease! when this number up to OS's open file limit everything is not OK.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)



More information about the jboss-jira mailing list