Swapping allows physical pages to be moved around, in the sense that a page used for one purpose could have its content swapped out then used for another purpose.
Under a garden variety virtual memory management system, there is no such thing as fragmentation of physical memory as far as applications are concerned. Each page allocated by an application can be taken anywhere in physical memory, there is no reason why two consecutive pages in virtual memory would need to have any particular closeness in physical memory.
There are many cases where memory fragmentation is a concern: any circumstances in which physical memory location matters. This includes:
- Paravirtualization, where virtual machines decide who owns which physical page at a granularity that is coarser than one page.
- Similarly, clusters where several nodes share the same RAM pool.
- Memory used by peripherals, which usually does require large contiguous buffers.
- Optimizations such as huge pages.
In the absence of “complex” scenarios, physical memory fragmentation could lead to problems connecting a new device that requires a pool of contiguous memory (the kernel keeps such pools for that, but they could need to be enlarged if a driver suddenly makes a large request). If device usage is constant, physical fragmentation would not matter and in particular would not cause an application to run slower or run out of space.
It's possible that fragmentation of the physical address space could lead to more memory being used in the kernel to represent the free list. I don't believe that this is the case in Linux but I'm far from being an expert on its memory management.
To summarize, allowing part of an application to swap does not enable this application to allocate more memory, but could enable some hardware drivers to allocate memory that they need.
Adding swap has no effect on the application's virtual memory space. That's the point of swap, after all — it's transparent to applications.
However, it is possible that adding swap to a machine would have an indirect influence on the fragmentation inside an application's virtual memory space. If the system runs out of virtual memory, then the application will have to make do with what it have. If the application is using most of the memory that it allocated from the operating system, this will over time cause fragmentation inside that space as small blocks are freed here and there. If the application has more virtual memory (some of which is swapped out), this gives the memory manager more room to maneuver and so reduces the risk that the application will run out of memory, with three separate 2kB blocks available when it wanted a single 4kB object.