improving memory management in sync thread