Over the years I've worked out a way that works for me to avoid error 12. I do still get one occasionally if I've decided to continue playing beyond the point I know I need to stop and refresh.
I find I can't let my game go over 3.2 GB of RAM used when playing. If it is over that point and I want to save I do a few things and usually do get it down below 3.2 GB. Thing I do include - moving down to a patch of grass or sand, going into map mode, going into edit town, going out over the ocean, changing to a different household with only one sim and a very basic house.
If none of that works, and any of them usually do work for me, I reduce my graphics. I reduce draw distance, number of lots visible and just about anything that will stop my game from needing more resources. but this type of thing is affected by the world I'm in at the time and how much complexity I've introduced to the game.
I also save often. The more often I save the less there is for the computer to hold in RAM and the less chance of an Error 12. But each time I save more junk seems to get retained by memory and that means I need to shut down the game and reload to fully clear the memory.
There are other things to try when reloading such as clearing cache files.