Fix memory leak on Java 1.7