SQL Server 2005 stored procedure assembly loading -
11-03-2005
, 09:13 AM
Hi
I'm trying to understand a little more about how loading of stored
procedure assemblies is implemented in terms of (client)
sessions/queries. Specifically, as a test, I've got a stored procedure
(implemented as a static method in a C# class) that writes to and reads
from a static class variable. If I invoke this method from two queries
in succession on the same connection, the changes made to the static
variable by the first invocation are not reflected in the second
invocation, which leads me to believe the stored procedure's class is
loaded into a different AppDomain for each query within the connection
i.e. the static members are not shared between queries. Is this
interpretation correct (I also note that changes to the variable made
by a procedure invocation are reflected in subsequent invocations
within the SAME query)? If so, at what point is the AppDomain
unloaded, please, since my primitive monitoring through Task Manager
suggests that the memory grabbed by the static variable is not
reclaimed immediately after the query returns.
As an observation, this seems to be in contrast to AS2k UDFs, where
data stored within a UDF's containing class seems to be accessible from
within other queries in the same connection (I know the differences
between AS2k UDFs and Yukon stored procs are vast, so this is no great
surprise)?
Thanks,
Jon |