Flushmem needs to be in the mainloop as it releases memory from any 'child' loop. In your program it is only releasing memory freed within that method. There is a thread somewhere which explains it (in the Bug Reports I believe).
Here
Why the hell can't I get this chuffing anchor tags to work???
<edit> FINALLY!!!
Here
Why the hell can't I get this chuffing anchor tags to work???
<edit> FINALLY!!!