Handle Leak Windows XP and Server 2003

  3 posts   Feedicon  
Replies: 2 - Last Post: April 21, 2010 14:51
by: tarad10
showing 1 - 3 of 3
 
Posted: April 19, 2010 12:52 by tarad10
I have written a program that sends bulk e-mails to an SMTP server using the JavaMail API. This program is not meant to be malicious or send spam. I work in the testing department at my company, and we have ACD e-mail routing for one of our products. As a means to fill the various e-mail queues on the supported mail servers (Exchange, GroupWise, Notes), we use the bulk e-mail app I have written.

Recently more attention has been paid to the ACD e-mail routing feature of our product, and more users are being e-mailed with the bulk e-mail app. This has uncovered a handle leak on Windows XP and Server 2003. It may exist on Vista/Windows 7/Server 2008 as well, but I have not tested it. The handle being leaked is this:

Type: Key
Name: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings

I have figured out that this key is created every time a transport connection event is called. I had been using the static Transport.send(Message msg) method. I have also tried reusing the same transport object as suggested in the FAQ for sending e-mails to multiple recipients. This works fine for sending one e-mail to 10 recipients, but if I want to send 5 e-mails simultaneously to 10 recipients only 1 or 2 e-mails make it to the users. Even this method is a work around though, because when I am done with the transport the handle is never cleaned up.

I believe the problem is with the Service Close() method. It does not appear to deallocate the handles that are created when the transport object connects. It could be an issue with the Service finalize() method (more of a long shot) as well, because the handle never appears to be garbage collected either. I am continuing to look for the problem in the source and creating custom java mail builds via trial and error. I thought getting another pair of eyes to look into it might be useful as well.

Thanks,
Aaron
 
Posted: April 21, 2010 05:29 by shannon
JavaMail is pure Java core - it knows nothing about Windows handles.

If there's a problem here, it's probably in the JDK. You might want to
upgrade to the latest JDK to see if it makes a difference.

As far as I know, JavaMail is correctly calling the close methods for all the
JDK resources it uses, such as socket connections. If you discover
otherwise, let me know.
 
Posted: April 21, 2010 14:51 by tarad10
I have done some tinkering, and I have figured out that this problem is only occurring when I connect to a remote SMTP server. So the issue is that network streams are not getting cleaned up. It is grabbing that particular handle, because my Java network settings are set up to use browser settings, and that is the registry key that stores those settings. I changed the settings to direct connect, but it grabs the same key.

I put the latest JDK on my system and rebuilt, but that did not seem to correct the problem. I put together another test that just grabs a URL with HttpURLConnections and InputStreamReader. The same handle is grabbed and even after I close the InputStreamReader the handle is not released. I am not sure if my code, the JDK, or Windows is to blame, but it is not the JavaMail API.

Thanks for your quick response and my apologies for the proverbial goose chase. I will try my luck on the Sun forums to see if someone can give me more general Java help there.

Thanks,
Aaron
Replies: 2 - Last Post: April 21, 2010 14:51
by: tarad10
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close