By memory poly settings I’m assuming you are referring to the max poly per mesh setting? This and the undo settings in my opinion come down to your personal preference, project needs, and computer power.
Personally, my computer’s default max poly per mesh setting of 21.8mil works for probably 95% of the things I do. I usually never come close to that amount of polys on a single sub tool. The only occasions when I might use near that many polys is subdividing to around 16mil polys to retain as much polypainting information as possible when using a 4096x4096 texture size. Even in that case though, the default setting for me works just fine. Other than that you may need more if you’re using a basemesh that doesn’t have a lot of edge looping so that you can sculpt whatever you need without having to fight the mesh too much. But then a quick retopology will easily free up plenty of polys. So in short, i’d recommend leaving it at the default until you run into an occasion when you need more polys and only up it then.
As for undos, the more undos you have, the more memory is dedicated away from sculpting and instead is used for storing undos. I personally find that the default is too low for my liking, so I usually raise it to around 10. However if you find that zbrush is running out of memory too fast then you should try decreasing the number of undos. Honestly, you can simply fix a lot of minor errors by resculpting over any mistakes. This is good practice and will help improve your sculpting abilities and lessen the need to use undos as a crutch. Obviously there are many occasions when a simple undo is far more convenient, like when adjusting brush settings or after making a major mistake.
There really are no right or wrong settings for these, you just have to play with them to find what works for you at the time.