fixed sql mem leak