> The way you make it sound, the instance of the UDF that is run stays
> in memory as long as there is a reference to the query that it
> contains.
No, the instance itself - the variable that corresponds to the
function itself - need not stay in memory. It will go out of scope
right after it runs, and will be eligible for garbage collection. But
the query that was created by that function will remain in memory
until all references to that query no longer exist.
> If I expanded the example to say that the UDF was a method of some
> component and was being called with a cfinvoke, the same case would
> apply. The component instance will stay in memory as long as a
> reference to the query exists, even though the query should be local
> to the UDF and nothing should be returned from the UDF.
No, again, the queries created by a method of a CFC don't depend on
the CFC's continued existence, as long as other references to those
queries now exist. This may be a bit counterintuitive, but the useful
thing to understand here is the difference between the stack and the
heap. References exist on the stack; the objects being referenced
exist in the heap.
> You also use the term "go out of scope" which I take to mean "can no
> longer be accessed, but still exists in memory". I assume this is
> linked to my other question about the memory used by invoked
> components being reused or not. If the memory is not reused, the
> component stays in memory but is no longer accessible ('out of scope')
Right. Once a variable name ("reference") goes out of scope, I can't
refer to the object to which that reference points unless there's
another reference pointing to the same object.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331514
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm