I am wondering if someone can help me understand why I should
or should not be concerned about returning local variables from a
called component - at least for datatypes that are passed by
reference rather than value. I am currently refraining from doing
this, since it appears that the calling routine would receive back
a pointer to memory that the CFC method would have released back to
the operating system upon its completion.
I've attached an example of what I'm talking about. When the
code is finished running, I expect mystruct will be a pointer to
the foo structure, which may or may not have been released to the
operating system after mycfcmethod completes.
So far I have been dealing with this safely, I believe, by
always returning a duplicated version of the results, such as
Duplicate(foo). I would like to avoid this extra overhead if it is
unnecessary. Possibly CF knows to hold onto any memory that is
referenced elsewhere, or possibly it doesn't.
Any insights would be appreciated.