First of all, yes it produces a memory leak, which can be verified by compiling with the heaptrc unit.
The reason for this is the following: GetInterface returns not an interface reference of R, but of Hook, as it is defined in:
//Here we tell the compiler that our class
//interface implementation is provided by
//a member field wich we initialize in this case
//on the constructor
property Hook: ITestInterface read FHook implements ITestInterface;
Therefore R will not be handled as an interface reference which circumvents the reference counting of it. Therefore it will not get freed.
Only references of the hook will be incresed and decreased by the use of the variable I, but as R still holds a reference, it will not drop to 0 and therefore not freed.
This causes two memory leaks, first R doesn't get freed and second the Hook of R doesn't get freed.
Solution: 1. remove the destructor of TRealClass, this is not needed as reference counting does the job.
2. Add an R.Free to the end of the program.
That said, IMHO this example is pretty bad and probably causes more confusion than helping anyone (the existance of this thread proof of that), this probably needs a rework and/or some explaination. There is no reason why TRealClass actually implements the TBaseObject, this let it seem like it itself provides the interface functionality while the whole example is to show that you can delegate that to a member/property. This makes this very confusing.
Generally speaking, an article called "How To Use Interfaces" could use more than one example, especially if that example only showcases a very corner case of interface usage (i would say delegating the interface implementation to a property is not really the main use case for interfaces), but could take more examples and maybe some explaination.
IMHO this article does more harm than good, as it is very confusing (and also simply broken), while not really giving any insight on how to use interfaces. It probably just scares people away of using interfaces rather than helping to understand them