[memory management] added infrastructure for releasing memory when it is tight. Release history buffers when needed