memory flush updated to be android friendly