Solved memory leak on OnChar function