Requirements: Termux, Root (preferably Magisk).
Open termux and give it root permissions
Type su
to escalate the permissions
Now enter the command dd if=/dev/zero of=swapfile bs=1024 count=6144k
replacing 6144k
with as much swap as you need, in this case 6GB
Once its done, enter mkswap swapfile
to create the sawp file and swapon swapfile
to enable the swap file