OP, I was in your situation at the same age, facing the same question of whether I would ever have kids if I didn't stay. I chose to stay, and here are some points I would make:
if you have children with someone you are actively unhappy with, not only do the children tie you to him forever (even if divorced, you're never fully free of each other) but also: the children will resemble him as much as they do you, so if that's a dealbreaker, act now.
but: frankly, based not only on what I thought then but what I see around me now, it would have been most unlikely I'd have had kids if I'd left, and nowadays, 20+ years later, it looks even more unlikely for your age group. Is that a dealbreaker for you? For me, it would have been -- and even in retrospect I think I made my only possible choice. My children have been the joy of my life, every bit what I wanted, even when they were (are!) being difficult pains in the a**.
ultimately, here's the real point: you will never be sure. If you stay, you will continue to have times when you look at him and wonder why you didn't cut your losses. If you leave, you will wonder how different and better your life MIGHT have been and may feel that you missed your chance. You will not necessarily be right, but you will never be sure, because how can anyone be sure?
It would be one thing if your DH (or mine) were a lost cause. If he's rotten, go sooner rather than later. But I read a helpful book, still in print, called: To Good to Leave, Too Bad to Stay, by Mira Kirshenbaum, who asked what I still think, decades later, is the right question:
When it was good, was it really good? Or were you already "settling"? If it wasn't good when it was good, leave. But if there was a time when it really was good, there's hope: counselling now may help, but also, you may find that it's quite usual to swing in and out of the good times together. That I think is quite normal.