free the results of the child albums SQL query for each album (this may be why the script uses so much memory)
remove commented out line that skips already exported albums (based on user specified starting album ID) since it's part of the SQL query that gets the list of albums.
output set id for debug purposes