SQL Server
(1)
ArrayList
(1)
Application
(1)
Hashtable
(1)
DR
(1)
Gettin
(1)
Doman
(1)
Tiem
(1)

CLR Shared Memory, C# DLL load

Asked By DR
29-Oct-07 03:28 PM
CLR Shared Memory, C# DLL load

How to share memory between CLR calls to the same C# dll? Is there some way
to know in the C# dll when the dll is loaded? Is the dll reloaded each tiem
a method is called from SQL Server or is the DLL loaded once when the C# dll
is added to sql server with CREATE ASSEMBLY?

I wold like to be able to share memory accross calls to methods on the same
C# dll is why. e.g. a Shared ArrayList or a shared Hashtable.

DR, Are you doing this in the same app domain?

Asked By Nicholas Paldino [.NET/C# MVP]
29-Oct-07 04:06 PM
DR,

Are you doing this in the same app domain?  If so, then a static member
is all you need.

However, if you want to do this in different application domains, then
you can't use shared memory from C# (I think there is a way to do it in C++
with the CLI extensions, but I'm not sure).  Rather, you would have to
create a service (not a literal one, but one instance which other app
domains communicate with) which will host the values and return them to the
callers.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

CLR Shared Memory, C# DLL load

Asked By Willy Denoyette [MVP]
29-Oct-07 04:57 PM
I'm not clear on what you mean with shared memory, are you talking about
memory mapped files, or something else?. I'm also not clear on what you are
trying to achieve here.
To answer the remainder of your question, whenever you call into a managed
function or SP for the first time, the host (SQL Server) loads the CLR which
at his turn creates an Application Domain (AD) and loads your registered
assembly into that AD. The CLR keeps this AD loaded, and with it, the loaded
assemblies, until something really bad happens or until the DB is taken
off-line. The SQL/CLR can reload the AD whenever something bad happens in
your code, but otherwise the assemblies stay loaded until the server stops
or until the DB gets detached. That means that once you have called into a
function/sp your (Jitted) code remains loaded in the SQL Server process
space.

Willy.

CLR Shared Memory, C# DLL load

Asked By DR
29-Oct-07 07:50 PM
http://rafb.net/p/vtxwnj70.html

see that post, it seems to return 1 each tiem as if the app doman keeps
gettin reloaded each time i call the clr sp
Post Question To EggHeadCafe