<html>
    <head>
      <base href="http://icedtea.classpath.org/bugzilla/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:sgehwolf@redhat.com" title="Severin Gehwolf <sgehwolf@redhat.com>"> <span class="fn">Severin Gehwolf</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - Resource leak in Thermostat byteman helper"
   href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2955">bug 2955</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>ASSIGNED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Assignee</td>
           <td>unassigned@icedtea.classpath.org
           </td>
           <td>ebaron@redhat.com
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - Resource leak in Thermostat byteman helper"
   href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2955#c10">Comment # 10</a>
              on <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - Resource leak in Thermostat byteman helper"
   href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2955">bug 2955</a>
              from <span class="vcard"><a class="email" href="mailto:sgehwolf@redhat.com" title="Severin Gehwolf <sgehwolf@redhat.com>"> <span class="fn">Severin Gehwolf</span></a>
</span></b>
        <pre>(In reply to Elliott Baron from <a href="show_bug.cgi?id=2955#c8">comment #8</a>)
<span class="quote">> (In reply to Severin Gehwolf from <a href="show_bug.cgi?id=2955#c7">comment #7</a>)
> > (In reply to Elliott Baron from <a href="show_bug.cgi?id=2955#c1">comment #1</a>)
> > > Alternatively, we could use the approach you mentioned of using a separate
> > > connection for each send operation. I don't believe any additional API is
> > > needed to make this work. I think the following should be sufficient:
> > > > ClientIPCService ipcService = ClientIPCServiceFactory.getIPCService(ipcConfig);
> > > > ByteChannel channel = ipcService.connectToServer(socketName);
> > > > channel.write(...);
> > > > channel.close();
> > 
> > I believe patch in <a href="show_bug.cgi?id=2955#c6">comment 6</a> would do this, but it does not fix the resource
> > leak. Thoughts?

> After investigating, I believe I've figured out the problem. A new instance
> of ThermostatHelper is not only created for each send operation, it is
> created for every time sleep is called.</span >

That makes sense. The rule instruments sleep(), the trigger point.

<span class="quote">> The Byteman rule we're using invokes
> send for every 10 times that sleep is called. This means only 1 out of 10
> sockets is closed if we try to close only when send is called. Another small
> issue with the patch in <a href="show_bug.cgi?id=2955#c6">comment 6</a>, is that there is an early return
> statement in the for-loop that prevents close from being called unless an
> exception occurs.</span >

Right, thanks. I totally missed the early return. Ugh :-/

<span class="quote">> Here is another patch that appears to fix the resource leak. The idea is to
> create the transport in the send method instead of the constructor. I had to
> add some synchronization to the close method, but if we intend to have a
> separate connection per send operation, we could remove most (or all) of the
> synchronization in Transport.</span >

I can confirm that this fixes the issue too. I'll do some more testing and will
report back to you.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>