title: Java app makes screen display unresponsive after 10 minutes of user idle time
body: <p>I've written a Java app that allows users to script mouse/keyboard input (<a href="http://jmacro.org" rel="nofollow noreferrer">JMacro</a>, link not important, only for the curious). I personally use the application to automate character actions in an online game overnight while I sleep. Unfortunately, I keep coming back to the computer in the morning to find it unresponsive. Upon further testing, I'm finding that my application causes the computer to become unresponsive after about 10 minutes of user idle time (even if the application itself it simulating user activity). I can't seem to pin-point the issue, so I'm hoping somebody else might have a suggestion of where to look or what might be causing the issue.</p>
  
  <p><strong>The relevant symptoms and characteristics:</strong></p>
  
  <ul>
  <li>Unresponsiveness occurs after user is idle for 10 minutes</li>
  <li>User can still move the mouse pointer around the screen</li>
  <li>Everything but the mouse appears frozen... mouse clicks have no effect and no applications update their displays, including the Windows 7 desktop</li>
  <li>I left the task manager up along the with the app overnight so I could see the last task manager image before the screen freezes... the Java app is at normal CPU/Memory usage and total CPU usage is only ~1%</li>
  <li>After moving the mouse (in other words, the user comes back from being idle), the screen image starts updating again within 30 minutes (this is very hit and miss... sometimes 10 minutes, sometimes no results after two hours)</li>
  <li>User can CTRL-ALT-DEL to get to Windows 7's CTRL-ALT-DEL screen (after a 30 second pause). User is still able to move mouse pointer, but clicking any of the button options causes the screen to appear to freeze again</li>
  <li>On some very rare occasions, the system never freezes, and I come back to it in the morning with full responsiveness</li>
  <li>The Java app automatically stops input scripting in the middle of the night, so Windows 7 detects "real" idleness and turns the monitors into Standby mode... which they successfully come out of upon manually moving the mouse in the morning when I wake up, even though the desktop display still appears frozen</li>
  </ul>
  
  <p>Given the symptoms and characteristics of the issue, it's as if the Java app is causing the desktop display of the logged in user to stop updating, including any running applications.</p>
  
  <p><strong>Programming concepts and Java packages used:</strong></p>
  
  <ul>
  <li>Multi-threading</li>
  <li>Standard <em>out</em> and <em>err</em> are rerouted to a javax.swing.JTextArea</li>
  <li>The application uses a Swing GUI</li>
  <li>awt.Robot (very heavily used)</li>
  <li>awt.PointerInfo</li>
  <li>awt.MouseInfo</li>
  </ul>
  
  <p><strong>System Specs:</strong></p>
  
  <ul>
  <li>Windows 7 Professional</li>
  <li>Java 1.6.0 u17</li>
  </ul>
  
  <p>In conclusion, I should stress that I'm not looking for any specific solutions, as I'm not asking a very specific question. I'm just wondering if anybody has run into a similar problem when using the Java libraries that I'm using. I would also gladly appreciate any suggestions for things to try to attempt to further pinpoint what is causing my problem.</p>
  
  <p>Thanks!</p>
  
  <p>Ross</p>
  
  <p>PS, I'll post an update/answer if I manage to stumble across anything else while I continue to debug this.</p>
  
  <p><strong>Update:</strong> my app involved multi-threaded processes each initializing their own Robot objects and creating input events asynchronously. I refactored the app to only contain one Robot singleton object, but the different processes still asynchronously invoke input commands. As far as I can tell, this did not change the behavior of my app. My next step might be to created a synchronized wrapper around the Robot singleton to see if that helps, but given the symptoms, I don't know why it would.</p>