update memory growth code, and ensure replace_memory is on the top in fastcomp