Inside your function, an object will be created on the stack. At the time of exit in the line with return, the following will occur. The object will be copied (or moved if it is from ++ 11 and everything is correctly described). The original object will be deleted. The question arises - where will it be copied ?. To do this, look at the point of call of this function. It will look like this somewhere.
MyClass mc = getMyClass(); // 1 случай
or so
mc = getMyClass(); // 2 случай
or even so
getMyClass(); // 3 случай
with the third case, everything is clear, most likely the object will not even be copied (just nowhere). There will be no memory leaks.
The second case is simple. We have an object and there is an object that is returned from the function. Your copy constructor should transfer the object carefully.
The first case is interesting because there are two possible options. In the first, an object will be created and then an object with a function is copied into it. In the second - the compiler can guess that the object will need to be copied, and allocate memory for it immediately in the right stack (in the stack of the calling function). In this case, the called function will not allocate memory in its stack, do copying and deleting. And sometimes the compiler does just that. This is a known bottleneck and it is based on the fact that you guarantee the compiler that the copy constructor correctly copies everything.
When do you need to make your own copy constructor? If you wrote your usual constructor, write a copy / destructor constructor. When do you need to be careful with the copy constructor? If the constructor code has nested classes or memory allocation through new (or alloc / malloc and the like. This is of course not much appreciated in C ++ code, but sometimes it is difficult without them).