It might be a memory or a RAM issue too. When my Macbook was having issues and kept crashing, my sister recommended I try Memory Clean - Free Up Memory from the App Store and see if that helped. That's what she used when her Mac Mini was acting up and it helped a lot. It's free on the App Store.
Another thing you could try which is a long-shot, but maybe run an antivirus scan just to be on the safe side that nothing weird got in.
Hopefully you don't need to replace yours. Mine ended up completly crashing on me and it would cost more for repairs than it was worth. Luckily, I had warranty still so I was given enough money to get a 21.5" iMac in 2014. I wanted another Macbook but they were more money than the iMac and I couldn't afford the difference at the time.
We recently bought my husbands parents a refurbished iMac 27" from about 2010, before they went with the thinner screens. We got a good deal on it for them so there are some out there if you need to invest in another one but can't get a brand new one.