fix memory leak when use menu_selector.
Merge pull request #8032 from joewan/v3-fix-leak

fix memory leak when use menu_selector.