as suggested by @hcheung after 5 second save data may call continuously which can append data multiple time and can cause out of memory.