How to know stack overflow

I have a question.
How to know maximum stack of my program and stack overflow?
beacause my program can lock when power have unstatable.

More questions in this forum