Why? You can know the reason from common programming languages. For example, the below C# while statement adds/removes local variables from stack for each iteration:
while (conditionIsMet)
{
string output = DateTime.Now.ToString();
int count = 0;
......
}
WF WhileActivity has similar logic for each iteration: to create a new AEC based on the template activity (e.g. the SequenceActivity inside the WhileActivity).
Will the new AEC be destroyed at the end of each iteration? You may think "Of course! This is an obvious question". But the answer is "yes or no".
The answer is yes for normal cases without the need for compensation. There will be only one new AEC in memory for the iterations.
But the answer is no when compensation is needed. If a CompensatableActivity is defined inside the WhileActivity and when an exception occurrs in one iteration, all the previous iterations will be compensated. That means all previous AEC's can not be destroyed after each iteration. They have to be in memory for compensation purpose.
According to Krishnan:"The runtime will clean up execution contexts after each WhileActivity iteration. But only if you don't have an ICompensatableActivity inside (if you do, the EC's will stay in memory until the next persistence point.)"