Maybe it's time for an upgrade. I mean, 512mb is a pitiful amount of RAM to have nowadays.
However, that's not what you asked for, so I'll try help you out.
If it's an overheating problem, as JT mentioned, then the two most likely culprits of this problem are the processor and the RAM. If it's the processor, you're better off just buying a new machine, since it would be far too cost-inefficient to replace. If it's the RAM, however, you should be able to pick up a couple of extra sticks fairly cheap (check websites like NewEgg and PCPartPicker).
Your problem sounds a lot like broken RAM, so you might want to check that out. Also, do what JT suggested and remove the hard drive - if booting gives you a "missing OS" error, or something of the sort then it's some sort of hard drive failure, and you'll have to replace that (again, probably more cost-efficient to just buy a new machine).
Good luck fixing your (hopefully) temporarily-busted laptop!