This is a strategy, but it typically falls apart against clever attackers who are targeting you specifically. Hackers have been performing return-to-libc attacks forever where they don't actually get to write any code at all, just sequence code that already exists in your binary.
Java also tried this in a slightly more rigorous manner with the SecurityManager and that just ended up being a botch.
Yeah that's why I said it really depends on the host language to make such sandboxing feasible. If you're using a language that lets code write arbitrary data to arbitrary memory locations, implementing a secure sandbox is going to be pretty tricky.
Java also tried this in a slightly more rigorous manner with the SecurityManager and that just ended up being a botch.