This article 2 explains the swap file in detail. In short: you can offload data to the swap file (located on your SSD/HDD) if you are running out of RAM.
Yes, reducing the batch size would help in case you are running out of memory.