How to check variable memory in GHpython

Not sure if it helps but last time I had a Python script using a lot of memory, I figured it related to the fact that it keeps the whole execution in the undo stack, which means you can undo the executed script after it has run.
What I ended up doing is to run a ClearUndo after each iteration.