How do you delete the swap space?

My 2015 Mac Book pro is running low on memory, and so it has switched to using the swap space. Though now the swap space is taking up all the computer's virtual memory. Is there any way to delete the swap space. I usually restart the computer to get back that space, but there has to be a smarter and easier way to get back that space.

enter image description here https://i.imgur.com/AYAr7lO.png

Out of disk space: enter image description here https://i.imgur.com/EVWbAqx.png

Also is there anyway to find out how that space is being used, like which applications are using the swap space?


You are thinking of this from the 'wrong side'.

Swap space is your virtual memory.
Swap space is essentially a high tide marker. if your Mac doesn't need the space, it doesn't need to try to aggressively reclaim it.
Your Activity Monitor screenshot shows "no issues".

Your actual issue is that your tiny boot drive is far too full for safe, normal operation.

Speculation
The issue that arises may be because the part of the OS handling memory is itself unaware of how full the drive is & always assumes if it needs memory, the drive is going to be there to provide it. It it isn't, then problems occur.
This perhaps then masks the actual issue from user perception.