Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php

I faced with the same issue when I was writing my backup plugin. The bug appear when you fetch all data from db by calling $wpdb->get_results( ... ). And as you can suppose it fetch all data into memory allocated for php. The better approach is to use mysql_* functions to fetch row one by one and store data into temporary file. This approach will reduce memory usage tremendously.

I would recommend you to do it something like this:

$result = @mysql_query( sprintf( 'SELECT * FROM `%s`.`my_big_table`', $wpdb->dbname ), $wpdb->dbh );
if ( $result ) {
    while ( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) ) {
        // save each row to temp file
        fwrite( $handle, prepare_row_to_save_into_file( $row ) );
    }
    @mysql_free_result( $result );
}