I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries:
$sqlstr = \"SELECT * FROM user_pred WHERE
Part of the reason you may be seeing additional used memory on every iteration is that PHP hasn't (yet) garbage collected the things that are no longer referenced.