fixes #4305 memory leak.
fixes #4305 GUI Samples memory leak.
Merge pull request #75 from chengstory/#4305

#4305 fixes leak memory.