Reasoning about memory management in resource-bounded agents