Re: ClientResource leaves inactive thread

2010-06-25 Thread Nina Jeliazkova
Tim Peierls wrote:
 What was the date of that snapshot? It looks like there's a fix as of
 June 11, revision 6696 in svn.
Not sure about the date, it's the snapshot, available in the maven
repository, 
http://maven.restlet.org/org/restlet/jee/org.restlet/2.0-SNAPSHOT/org.restlet-2.0-SNAPSHOT.pom


I would actually prefer a configurable ClientResource, to be able to
switch on/off launching separate threads - does this already exist?

Best regards,
Nina

 But (talking to Jerome and Thierry now) I'm a little worried that this
 fix isn't really addressing the heart of the problem. In particular,
 the use of thread pool per BaseHelper instance prevents efficient
 re-use of threads in the JVM. 

 Also, defaulting coreThreads=1 and maxThreads=255 with a
 SynchronousQueue seems like it's asking for trouble with CPU count 
 255. What about a bounded queue with high capacity to get through the
 bursts, but keep the pool size to some small multiple of the CPU
 count? Remember that core size is _not_ really min size.

 (And a minor nit: BaseHelper.workerService is a volatile instance
 field, so visibility isn't problem, but there are some atomicity
 issues -- at init time and shutdown time. Fix to the latter just means
 copying volatile value to local variable before testing and using.
 Fixing former ... needs some thought. Maybe it's OK as is.)

 --tim

 On Tue, Jun 22, 2010 at 6:02 AM, Nina Jeliazkova n...@acad.bg
 mailto:n...@acad.bg wrote:

 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; 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

 P.S. Inactive threads while executing the example above




--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2625730

Re: DirectoryServerResource and directoryRedirection

2010-06-25 Thread Alexander Kampmann
hi, 

look at the way routing works: 
http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/326-restlet.html. 
You may either change your matching mode to MODE_START_WITH or use one of the 
tricks from the routing and queries- section. 

Alex

 Original-Nachricht 
 Datum: Wed, 23 Jun 2010 12:05:35 -0700
 Von: William Pietri will...@scissor.com
 An: discuss@restlet.tigris.org
 Betreff: DirectoryServerResource and directoryRedirection

 Hi! I'm just getting into the 2.0 release while building a Facebook app 
 and am puzzled by something.
 
 Right now I have some content, served up by a Directory, at a location 
 like this:
 
  http://example.com/welcome/
 
 
 Outside of the Facebook context, this is fine. However, the way I'm 
 doing the Facebook app, my pages appear inside an iframe on Facebook's 
 page. To pass along context information, they add a bunch of parameters 
 to the URL, so it looks something this:
 
  
 http://example.com/welcome/?fb_sig_in_iframe=1fb_sig_iframe_key=...fb_sig=fe82...ec467a9e
 
 
 The DirectoryServerResource decides that since that doesn't end in a 
 slash, it couldn't possibly be a directory, and so throws a slash on the 
 end and issues a 303. That seems weird to me, but I'm not sure if this 
 is just an odd use case not yet supported, or if there's something 
 irredeemably wrong about the Facebook approach. Or, most likely, that 
 I'm not using Restlet in the right way, and that I should be approaching 
 things differently.
 
 Any thoughts on how I should handle this?
 
 William
 
 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2625164

-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2625367