Hi Nina, I've just tested your program with SVN trunk and it doesn't leave active threads anymore. This should also work with version 2.0.0 as we are now stopping the HTTP Client connectors automatically (they are created by the ClientResource instances when run outside a Restlet application context) when the GC is running.
Best regards, Jerome -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -----Message d'origine----- De : [email protected] [mailto:[email protected]] Envoyé : mardi 22 juin 2010 22:33 À : [email protected] Objet : ClientResource leaves an inactive thread Hello All, I am experiencing memory/thread leak ,with Restlet-2.0-RC4 and Restlet-2.0-SNAPSHOT , when using ClientResource. Basically, ClientResource doesn't close the thread it spawns and this result in number of inactive threads and severe memory leak. Here is some very simple code to illustrate this behaviour. The same code runs fine in Restlet-2.0-M6 (which doesn't span new thread in ClientResource). public void run(int instances) throws Exception { for (int i=0; i < instances;i++) { ClientResource clientResource = null; Representation r = null; try { clientResource = new ClientResource("http://restlet.org"); r = clientResource.get(); } finally { try { r.release(); } catch (Exception x) {} try { clientResource.release(); } catch (Exception x) {} } } } public static void main(String[] args) throws Exception { ThreadTest test = new ThreadTest(); test.run(1000); } I guess there might be something missing in the code to explicitly close threads, but since the same code runs fine in M6, it is quite confusing to experience leaks after upgrade. Best regards, Nina Jeliazkova ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2624682 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2652832

