memoryrealease function has been changed
changes from main are merged