Programs could be explicit about those constraints, encode more of them statically and check them statically.
Statically encoding something like a memory constraint sounds very hard for all but the simplest algorithms. What about a randomized algorithm that sometimes uses more heap? How do you get around not knowing how much it's going to use without running it?
What you're describing is essentially a proven, lightweight, formal method for improving software quality. Many commercial apps use it.