I have a theoretical question, What would happen if I clean up all the swap space while running, Would the operating system crash because of page faults that would happen in the kernel?
Overwriting swap with random values is equivalent to overwriting process images in memory with random values.
If a text segment with random values is executed, the most likely result is process termination due to an illegal instruction (signal
If a data segment with random values is read, the result is most likely process termination due to a segmentation fault (signal
SIGSEGV), because pointers will point outside the process's address space. Note that pointers are data, just like scalars. Especially the stack usually contains several pointers; when a return instruction is executed, a random stack entry causes a jump to a random address.