Does WordPress import export tool keeps the file hosted on the old website?

Does WordPress import export tool keeps the file hosted on the old website?

No, the import/export tool creates a WXR file for posts/terms, WXR exports include the attachments from the database, but they do not include the files themselves.

When you import the WXR though, it will ask if you want to download the assets from the original server.

Since you’ve stated you have multiple gigabytes of assets, it’s almost guaranteed that this will take longer than the maximum PHP execution time and fail unless you do it via WP CLI, or break your WXR into multiple smaller chunks.

This is of course not taking into consideration alternative methods of migrating data, such as raw SQL, downloading media via FTP and uploading it, search replace, etc ( I’d advise asking a new follow up question about each of those ).

my concern is that the media files remain hosted on the old site and are accessed from there, even though they appear to be on the new site. so if i deleted the old side i lose all the media data.

Correct. If you delete your old site without migrating media, all your media is destroyed.