First of all, are you getting any strange tones when it tries to start back up? I know most people would mention this if it did, but you'd be surprised. Those tones are error codes that he machine gives you.
Are you getting any strange text across the screen with a strange grey background? (Kernel Panic)
My best guess with limited information on any behavior other than freezing and restarting itself is a RAM issue. If the RAM locks up, it could shut itself down (or restart) to prevent any real damage that can occur during a lockup.
Try following the steps for a PRAM (NAVRAM) reset.
Power down your machine.... and remove all peripherals.
- Press the power button to boot your machine.
- Before the screen lights up (as soon as possible) hold down (opt + command + P + R)
- Do NOT let go when you hear the chime!
Your machine will act as if it is going to boot, you will hear the drive engage. KEEP the buttons held down.
- You will then hear a second chime. Once you hear that chime you can let go of all of the keys at the same time.
Once your system fully boots, you can then reconnect your peripherals. Also, make sure that you check for any updates and are running the most up-to-date OS and version of that OS, as they often come with patches and fixes for any bugs that could be causing the errors.
IF for some reason this doesn't work... Try an SMC Reset.
HOWEVER... if the NAVRAM reset did work.... then keep in mind that you are gong to have to replace one or all of your currently installed RAM. Good news, right? Sorry.