I will try to answer your question, but first, I will have to explain the opposite of the ref keyword, and that would be autoptr. autoptr would be concidered a weak reference to memory, and any object variable marked as a autoptr would be removed from memory after hitting the end of the scope, IE the next closing curly bracket. Alternatively, ref is a strong reference forcing the variable to stay in memory until the object's destructor is called, or where ever you plan to release it.
I only use ref on class variable types, and the generic types for arrays/maps/sets, but never anything else.
You always have my discord if you have questions.