I attach two methods that should do the trick.

    /**
     * Releases internal buffer.
     *
     * @see Object#finalize()
     */
    public void release() {
        if (buf != null) {
            buf.release();
            buf = null;
        }
    }

    /**
     * @see Object#finalize()
     */
    protected void finalize() throws Throwable {
        try {
            release();
        } finally {
            super.finalize();
        }
    }

Reply via email to