trying to solve memory leak problem.. no idea what is causing mysql to get locked :(