added memory monitoring loop