An integrated hardware/software approach for run-time scratch-management