Menu
  • HOME
  • TAGS

Eclipse warns about a potential resource leak although I have a finally block which closes the outermost stream, what am I missing?

java,eclipse,streamreader,resource-leak

Eclipse probably just isn't understanding the shuffling you're doing with the res variable. I recommend using the try-with-resources statement (available in Java 7 and up, so three and a half years now), it dramatically simplifies these sorts of chains: public static String fileToString(String fileName, String encoding) throws IOException { try (...

Is JDK ClassLoader.getResourceAsStream broken? (unclosed resources)

java,resources,classloader,java-8,resource-leak

I made a simple test program to verify the actual behavior: System.out.println(System.getProperty("java.version")); URL testURL = new URL("test", null, 0, "/", new URLStreamHandler() { protected URLConnection openConnection(URL u) throws IOException { System.out.println("creating connection to "+u); return new URLConnection(u) { InputStream is; public void connect(){} @Override public InputStream getInputStream() throws IOException {...

Try with Resources: Resource leak while closing resources in TWR block

java,java-7,try-with-resources,resource-leak

So if while closing an FileInputStream an expression exception is generated, since the expression exception will be suppressed , the resource is not closed... You don't know it isn't closed, just that you got an exception while closing it. ... Will it generate a resource leak ? It may...

Is there a difference in disposing Icon and Bitmap?

c#,winforms,gdi,resource-leak

I believe that you have to take care of the icons manually. I did some searching and found that GC takes care of the bitmaps but not the icons. The forms sometimes keep their own copy of the icons (i'm not sure why). A way to dispose icons can be...

if a linux program exit with coredump, the unclosed files may lead a resource leak

linux,coredump,resource-leak

It will close them as well. Although core dump abruptly terminates the program, the OS can still perform all normal clean-up routines it would do if the program terminated correctly.

Resource Leak: 'rset' is not closed at this location

java,memory-leaks,resource-leak

You should close the rset after you're done checking for "not found player". You're executing a new query afterwards, yet not closing the previous resultset -> resource leak....