monkey patch memory free issue