More notes:

- The leak is of closed ConnectionHandler's.

- The leak is through DataReply.ReplySendDone objects that are stored in KeyedMM
  which are in turn stored in the MM hashtable.  What should be the lifetime of
  these objects?

- I've only tested this with FProxy nodes, so it could be something to do with
  the way FProxy works.  For example, it could be due to the fact that the
  initial request is not another node, but an HTTP request.

So if someone could review that part of the code...

Should I go ahead and check in my fix?

On Sun, Dec 31, 2000 at 12:50:12PM +0100, Oskar Sandberg wrote:
> On Sat, Dec 30, 2000 at 07:31:50PM -0800, Dev Random wrote:
> > I took a quick look at the memory situation, and there is a leak there.  The
> > problem is that the Message class keeps a pointer to the ConnectionHandler.
> > Subclasses of Message are kept in the Node in messageMemories.
> 
> It has to do that to function.
> 
> > For every ConnectionHandler that is leaked, there are 128KB of buffer space, so
> > the leak is pretty fast.
> 
> Every ConnectionHandler is also a thread, so it will live regardless of
> whether there are references to it. If we have tons of MessageMemories
> lying around long after there connections are dead, then we have a
> problem right there.
> 
> > I've attached a proposed fix.  It works for me, but someone should review it
> > before I check it in.  In the patch I have the ConnectionHandler null-out
> > its members when closed.  Another approach would be to have the Message
> > null-out the ConnectionHandler, but I'm not sure where in the code that
> > should be done.
> 
> Nulling out the variables when you close won't do any harm. You would need
> a reference back to the message to tell it forget the ConnectionHandler.
> 
> And I still don't see where all these messages are coming from - the only
> time I can think of when a message is stored in the MM is between the
> StoreData is received and when it is sent. And once it is sent the MM is
> killed.
> 
> > (BTW, the flags I've used are '-verbosegc' and '-Xrunhprof'.  SIGQUIT causes the
> > latter to dump a snapshot to java.hprof.txt.  Look for "SITES BEGIN" in that
> > file and then under the 'live objects' column.)
> > 
> > -- 
> > Dev Random
> > Fingerprint: 3ABC FCEF 1BCE 4528 E4FD  15EB 173A 76D2 6959 DAF1
> 
> > Index: ConnectionHandler.java
> > ===================================================================
> > RCS file: /cvsroot/freenet/Freenet/ConnectionHandler.java,v
> > retrieving revision 1.70
> > diff -u -r1.70 ConnectionHandler.java
> > --- ConnectionHandler.java  2000/12/05 09:57:29     1.70
> > +++ ConnectionHandler.java  2000/12/31 03:17:24
> > @@ -80,12 +80,17 @@
> >             Core.logger.log(this,"Failed to initialize connection: " + e,
> >                             Logger.MINOR);
> >             closed = true;
> > +           synchronized (c.initLock) {
> > +               c.initLock.notifyAll();
> > +           }
> >             forceClose();
> >             return;
> >         } finally {
> >             sendLock.notifyAll();
> > -           synchronized (c.initLock) {
> > -               c.initLock.notifyAll();
> > +           if (c != null) {
> > +               synchronized (c.initLock) {
> > +                   c.initLock.notifyAll();
> > +               }
> >             }
> >             synchronized (initLock) {
> >                 initLock.notifyAll();
> > @@ -206,7 +211,7 @@
> >         lastActiveTime = System.currentTimeMillis();
> >     } while (!closed);
> >  
> > -   if (c.out != null) {
> > +   if (c != null && c.out != null) {
> >         Core.logger.log(this,"Finished with connection - closing",
> >                         Logger.DEBUGGING);
> >         forceClose();
> > @@ -233,7 +238,7 @@
> >       */
> >      public void sendMessage(Message m, MessageObject mo) 
> >     throws SendFailedException {
> > -   while (!c.ready() && !closed) {
> > +   while (!closed && !c.ready()) {
> >         synchronized(initLock) {
> >             try {
> >                 initLock.wait();
> > @@ -241,7 +246,8 @@
> >         }
> >     }
> >  
> > -   if (closed) throw new SendFailedException(c.getPeerAddress());
> > +   if (closed)
> > +       throw new SendFailedException((c == null) ? null : c.getPeerAddress());
> >  
> >     synchronized(sendLock) {
> >         unlockedSend(m, mo);
> > @@ -320,6 +326,9 @@
> >      public void forceClose() {
> >     closed = true;
> >     c.close();
> > +   c = null;
> > +   t = null;
> > +   mh = null;
> >     exec_instance.interrupt();
> >      }
> >  
> 
> 
> 
> 
> -- 
> 'DeCSS would be fine. Where is it?'
> 'Here,' Montag touched his head.
> 'Ah,' Granger smiled and nodded.
> 
> Oskar Sandberg
> [EMAIL PROTECTED]
> 
> _______________________________________________
> Freenet-dev mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/mailman/listinfo/freenet-dev

-- 
Dev Random
Fingerprint: 3ABC FCEF 1BCE 4528 E4FD  15EB 173A 76D2 6959 DAF1

PGP signature

Reply via email to