Out of Memory Error

Anyone know why the following produces an "out of memory" error?

Let (
		A = "Name is ";
		B = GetValue (Substitute (GetFieldName (Contact::record__ctl); "::"; "¶"); 2)
	A & B

Did a little more digging. Pretty much everything fails, even this:

GetFieldName (Contact::record__ctl)

Yet, when I change the context from the Contact table to any other table, it suddenly works. Only problem is, changing the context defeats the purpose of my calculation. The one in the OP is a simplified calculation to illustrate my problem.

I would appreciate it if someone can explain the issue so that I may formulate a solution.

I continued my investigation and found a pattern. GetFieldName will fail with an out of memory error if its parameter is a potential or real recursive calculation field and the context allows it to be reached. I conclude that GetFieldName somehow evaluates the field when context allows it.

I also posted the same question to the Claris Community. I got an interesting response from Alex Zueiv. He pointed me to a two-year-old article: GetFieldName Revisited – FileMakerHacks. In short: the performance of GetFieldName is affected by the relationship graph… and it can be slow. This fits the pattern I observed.

Hope this helps.