Skip to content

Commit

Permalink
Merge pull request #397 from Gordiychuk/memory_leak_in_backtrace
Browse files Browse the repository at this point in the history
fix: avoid memory leak when redeploying pgjdbc
  • Loading branch information
davecramer committed Oct 13, 2015
2 parents a194c5e + d7cab7b commit 09d7b77
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
Expand Up @@ -2217,7 +2217,18 @@ public long getLong(int columnIndex) throws SQLException
* the exception is always caught and is not visible to users.
*/
private static final NumberFormatException FAST_NUMBER_FAILED =
new NumberFormatException();
new NumberFormatException() {

// Override fillInStackTrace to prevent memory leak via Throwable.backtrace hidden field
// The field is not observable via reflection, however when throwable contains stacktrace, it does
// hold strong references to user objects (e.g. classes -> classloaders), thus it might lead to
// OutOfMemory conditions.
@Override
public synchronized Throwable fillInStackTrace()
{
return this;
}
};

/**
* Optimised byte[] to number parser. This code does not
Expand Down

0 comments on commit 09d7b77

Please sign in to comment.