Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Resource leak, Std library  RSS feed

 
joseph Anderson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so DrJava's console is giving me the warning "Resource leak: 'manager' is never closed"

Is this something i should worry about? And why is this occurring? I don't ever remember this happening before when using stdIn

 
joseph Anderson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay nevermind, I figured out that i dont even need scanner, just need stdIn.readInt()
 
Campbell Ritchie
Marshal
Posts: 55672
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IDEs (and obviously DrJava) are programmed to notice readers, writers, etc., which are not closed. If you open a reader pointing to a file and never close it, the file may become inaccessible to other code, we hope temporarily. So they give you a warning, which you can overlook. Try opening and closing a Scanner pointing to System.in and you will find out why you should ignore such warnings whenever System.in System.out and System.err are involved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!