background thread memory management