Yes the hard drive does need space for the virtual memory - normally it is recommended that there be at least 10% of the disk space free.
However when there is insufficient memory you normally get a warning saying so and all that happens is the machine locks up.
The fact that it is switching off completely may mean another problem.
It could be a heat issue. Have you checked all the fans are working and clear of gunk?
It could be that the power supply unit is on the way out.
It could be a defective hard drive - try and run the HDD manufacturers diagnostic application.