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

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


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

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

Ah, this is because XNIO caches the poll selector in a ThreadLocal. If you use an ExecutorService or some other fixed thread pool you will not have the issue. It still should be GCed at some point though.

> 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