If my application is out of memory when i call new() i will get exception and malloc() i will get 0 pointer.
But what if i call a method with some local variables? They occupy memory too. Is there some way to reserve memory for “normal” variables? So that even though new() throws exception i can just catch it, fix stuff and still call methods like usual.
The compiler knows how much of memory per stack you need. However, sufficiently high number of stacks (caused due to recursion) will crash your program — there probably isn’t another way to fix this.
The standard has an interesting annexure called Implementation Quantities. This is non-normative (informative) and hence should not be treated as the absolute truth, but provides you with a fair idea.