 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stephen Berard Guest
|
Posted: Tue Dec 09, 2003 5:10 pm Post subject: SUN 1.4.x JVM: Windows Event handle leak |
|
|
I have an application that is leaking handles when running under the
Sun 1.4.x JVMs on Windows XP Pro. Running under 1.3.1 the same code
does not leak. Under further investigation it appears that the
handles are Windows Event handles. This can be seen in the Windows
Task Manager and Performance Manager.
I have narrowed it down to a section of code that performs a polling
loop (code is too lengthy to post). The polling loop is a
synchronized queue. Items are popped off the queue and processed.
The results are returned in a result object (whose access methods are
synchronized). Then the item is placed back on the end of the queue.
There is a pause (2-3 seconds) between the processing of each item.
The processing of each item involves a JNI call to obtained data via
USB. (This code has not been modified and runs correctly under 1.3.x
JVMs).
The strange thing is that handles only leak occasionally. If I leave
my app running for a few hours I may leak 5-10 handles. This has no
correlation to the number of items processed or the number of times
through the full poll loop. The only clue I have is that the garbage
collector seems to be running when a handle leak occurs. However, a
handle leak does not occur on every GC cycle. I suspect that this
problem has something to do with synchronized objects. What's weird
is that this same exact code runs perfectly on 1.3.1.
Has anyone else seen similar behavior? Any clues on how to debug
this?
Thanks for your help,
Stephen
|
|
| Back to top |
|
 |
Michael Amling Guest
|
Posted: Thu Dec 11, 2003 2:49 pm Post subject: Re: SUN 1.4.x JVM: Windows Event handle leak |
|
|
Stephen Berard wrote:
| Quote: | I have an application that is leaking handles when running under the
Sun 1.4.x JVMs on Windows XP Pro. Running under 1.3.1 the same code
does not leak. Under further investigation it appears that the
handles are Windows Event handles. This can be seen in the Windows
Task Manager and Performance Manager.
I have narrowed it down to a section of code that performs a polling
loop (code is too lengthy to post). The polling loop is a
synchronized queue. Items are popped off the queue and processed.
The results are returned in a result object (whose access methods are
synchronized). Then the item is placed back on the end of the queue.
There is a pause (2-3 seconds) between the processing of each item.
The processing of each item involves a JNI call to obtained data via
USB. (This code has not been modified and runs correctly under 1.3.x
JVMs).
The strange thing is that handles only leak occasionally. If I leave
my app running for a few hours I may leak 5-10 handles. This has no
correlation to the number of items processed or the number of times
through the full poll loop. The only clue I have is that the garbage
collector seems to be running when a handle leak occurs. However, a
handle leak does not occur on every GC cycle. I suspect that this
problem has something to do with synchronized objects. What's weird
is that this same exact code runs perfectly on 1.3.1.
Has anyone else seen similar behavior? Any clues on how to debug
this?
|
Can you define the term "leak"? What symptoms lead you to the
conclusion that "handles" are "leaking"?
--Mike Amling
|
|
| Back to top |
|
 |
Stephen Berard Guest
|
Posted: Thu Dec 11, 2003 7:37 pm Post subject: Re: SUN 1.4.x JVM: Windows Event handle leak |
|
|
Michael Amling <nospam (AT) nospam (DOT) com> wrote
| Quote: | Stephen Berard wrote:
I have an application that is leaking handles when running under the
Sun 1.4.x JVMs on Windows XP Pro. Running under 1.3.1 the same code
does not leak. Under further investigation it appears that the
handles are Windows Event handles. This can be seen in the Windows
Task Manager and Performance Manager.
I have narrowed it down to a section of code that performs a polling
loop (code is too lengthy to post). The polling loop is a
synchronized queue. Items are popped off the queue and processed.
The results are returned in a result object (whose access methods are
synchronized). Then the item is placed back on the end of the queue.
There is a pause (2-3 seconds) between the processing of each item.
The processing of each item involves a JNI call to obtained data via
USB. (This code has not been modified and runs correctly under 1.3.x
JVMs).
The strange thing is that handles only leak occasionally. If I leave
my app running for a few hours I may leak 5-10 handles. This has no
correlation to the number of items processed or the number of times
through the full poll loop. The only clue I have is that the garbage
collector seems to be running when a handle leak occurs. However, a
handle leak does not occur on every GC cycle. I suspect that this
problem has something to do with synchronized objects. What's weird
is that this same exact code runs perfectly on 1.3.1.
Has anyone else seen similar behavior? Any clues on how to debug
this?
Can you define the term "leak"? What symptoms lead you to the
conclusion that "handles" are "leaking"?
--Mike Amling
|
Using PerfMon or the Task Manager the number of handles increases over
time. This does not happen with the 1.3x JVMs, they remain relatively
flat. I did a bit of investigation and what's happening is that the
JVM is creating a number of unname NT Events.
I have see a few posting on Sun's Java forum from people having
similar issues. Here are some links:
http://forum.java.sun.com/thread.jsp?forum=37&thread=439546
http://forum.java.sun.com/thread.jsp?forum=4&thread=452929
Just to be clear, I'm not 100% sure that this is a leak. The handle
count goes up by a random amount; it does not seem to be related to
anything in my program. I have tried polling more, polling less,
adding items to the poll list, make the poll list smaller, etc. It
looks to me like a race condition.
Any help is appreciated.
Cheers,
Stephen
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|