Get file absolute path from file URL in PHP
This should be the most cross platform way and uses less memory (also doesn't depend on wp)

function get_file_path_from_url( $file_url ){
   return realpath($_SERVER['DOCUMENT_ROOT'] . parse_url( $file_url, PHP_URL_PATH ));
}


It uses the native PHP function realpath().