Account for stack allocation in the thread's allocation counter

Authored by simonmar.