fix potential memory leaks for iOS