One of the major complications of a heart surgery is stroke. You might have suffered a mild stroke while undergoing surgery or soon after and hence the symptoms of memory loss and confusion. The symptoms will get better with a proper management plan that involves medication, exercises, good nutrition and psychotherapy. Please consult a neurologist for the complete neurological examination and management. Hope this helps you. Take care and regards!