Skip to content
Browse files

fix: avoid memory leak when redeploying pgjdbc

FAST_NUMBER_FAILED is used as a control-flow-exception pattern, thus it does not require a stacktrace.
It turns out Throwable might store strong reference to a class, thus it might result in OutOfMemory

closes #394
  • Loading branch information
vlsi committed Oct 12, 2015
1 parent a194c5e commit d7cab7bd86e4adde0aa0a2fb4a6dfed59cf05cd8
Showing with 12 additions and 1 deletion.
  1. +12 −1 org/postgresql/jdbc2/
@@ -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.
public synchronized Throwable fillInStackTrace()
return this;

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

0 comments on commit d7cab7b

Please sign in to comment.