When is it safe to call cuCtxCreate, if memory is low?

I have an interesting catch 22 situation.

I need to call cuMemInfo to see how much memory is free

In order to do that I need to create a context, which is done by calling cuCtxCreate

This uses memory.

If memory is already at breaking point this command fails, without an exception or return result in C++, so my program just hangs.

How can I know that it is safe to call cuCtxCreate?