implement behaviour similiar to "dont keep activities"

view story

http://stackoverflow.com – There's a scenario in my app which it could go activity a->activity b->activity a->activity b...infinitely, and eventually it'll get OOM. Is anybody aware of a way to make it like the "dont keep activities" behaviour,e.g. the activities will be killed to release memeory but still in history, so it can be recreated as user navigates back? (HowTos)