thanks for next suggestion, I tryied that, unfortunately it doesn't help, also you have one little error in your posted script, undef($dbh) should be before $pm->finish. Any more ideas ? :)
I really don't know how to solve this, I have around 15.000+ iterations, so I will always run out of memory by using this :(