Free memory before calling launchProgram