Fix the mem file generation bug