Improve the download of large files

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Check for free memory first

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>