Questions tagged [resource-leak]

208 questions
5
votes
1 answer

Is JDK ClassLoader.getResourceAsStream broken? (unclosed resources)

I will try to prove that ClassLoader.getResourceAsStream() is opening two InputStreams, closing none of it and returning only one to client. Is my logic correct? JDK sources are picked from jdk1.8.0_25 I've get into unclosed resources problem using…
Piotr Müller
  • 5,323
  • 5
  • 55
  • 82
5
votes
1 answer

Why compiler warns about resource leak?

I cannot understand why compiler warns me about a resource leak (Resource leak: 'conn' is not closed at this location) in the following code: Connection conn = null; try { conn = DatabaseConnectionPool.getConnectionFromPool(); …
m0skit0
  • 25,268
  • 11
  • 79
  • 127
5
votes
2 answers

How does IOUtils.closeQuietly hide the "resource leak" warning?

Background There is a nice function I use on IOUtils called "closeQuietly" , which closes the stream no matter what is in there. for example: InputStream input = null; try { ... input = connection.getInputStream(); ... } catch(Exception…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
5
votes
1 answer

What happens to file descriptors in Python 3 when .close() fails?

The following Python 3 code exhibits some strange behavior (to me, at least) when I run it through strace: import os import sys if len(sys.argv) != 2: print('Usage: ecpy ') sys.exit(1) try: print('my PID: %d' % os.getpid()) …
Samuel Isaacson
  • 345
  • 3
  • 6
4
votes
1 answer

Jersey client connection close memory leak issue

I am using Jersey v10 and have written the following code.Is this the right way to close a Jersey client connection to avoid memory leaks.I was not doing any calls int he finally before this. ClientConfig config = setupHttps(); final Client c =…
Vijay
  • 595
  • 1
  • 13
  • 27
4
votes
1 answer

Background of "resource leak: stream is never closed"

Given a Java function which uses a stream: List function(List input) { Stream a = input.parallelStream(); Stream b = a.map(c -> c.toString()); return b.collect(Collectors.toList()); } Now, I want to…
Matthias Ronge
  • 9,403
  • 7
  • 47
  • 63
4
votes
2 answers

How do I track down a Windows USER object leak?

I have a program that is leaking USER objects which can be seen in Task Manager. Is there a way to determine which type of resource is being leaked? I've used programs like GDI View for GDI leaks which breaks it down by object type. Is there…
Ryand
  • 436
  • 4
  • 16
4
votes
1 answer

If a Go sql.DB is closed, do any unclosed prepared queries get closed?

In a Go program using database/sql, will any unclosed prepared queries be closed when I Close the Postgres DB I'm using? I've cut this down to a very simple example that does not need the Prepare but still shows the question (I believe I could just…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
4
votes
3 answers

How to solve failure to close a FileStream

I have closed file steam in try/finally, but code analysis warns me: Possible failure to close a FileOutputStream Possible failure to close a PrintWriter Possible failure to close an OutputStreamWriter How can failure happen? How can I ensure…
tensor
  • 43
  • 2
4
votes
1 answer

How should I go about debugging a Mach port leak?

I have a server written in c++ that leaks Mach ports when run on osx. Specifically, when running top I noticed that it had around 50000 (under #PORTS) . Curiously, I left it running overnight and the next day the machine was basically dead (took…
Bwmat
  • 4,314
  • 3
  • 27
  • 42
4
votes
5 answers

Diagnosing Cause of 100% CPU Usage by "System" Process

I have a Windows server application, implemented in C++ using the Win32 API, that does a lot of serial and TCP/IP communication. As it runs, CPU usage gradually increases, until it reaches 100%. Task Manager indicates that most (>75%) of the CPU…
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
4
votes
4 answers

COM:Can i call CoUninitialize without calling Release?

I have a doubt. I initialize COM, do CoCreateInstance and use some interfaces.Can I call CoUninitialize without calling Release? Does it cause any memory/resource leak? Thanks in Advance, -Mani.
Manigandan
4
votes
1 answer

Where was handle allocated?

I am wondering if it is possible to use WinDbg to kwown the callstack that lead to the allocation of a handle. For example: #include #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { …
Jorge Ferreira
  • 96,051
  • 25
  • 122
  • 132
4
votes
2 answers

Eclipse 4.2 resource leak through separate close method

I'm using Eclipse 4.2 with resource leak warnings enabled. This code produces an, in my opinion false, resource leak warning. public static void test(){ InputStream in = null; try { in = new FileInputStream("A"); } catch (IOException e)…
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
3
votes
0 answers

Leaking handles when using std::shared_mutex in Windows

Same question here: Memory leaks using shared_mutex but in Windows 11. The Windows handles are not being closed. #include using namespace std; #include extern "C" { #include } int GetHandleCount()…
Bil_Bomba
  • 183
  • 1
  • 8
1 2
3
13 14