What happens when session keys are assigned and deleted?

I use session variables to store objects, assigning them to the corresponding session key. Because these variables are session-specific, they are not collected by the garbage collector, but rather are cleared by the session timeout. To remove these session variables, I must delete the key that contains the object that I no longer want to use.

When assigning an object to a session variable, does this session key point directly to the object's link or creates another link?

And when the session key containing the object is deleted using .Remove (), does this delete delete that memory space or still exist under the hood, but without the associated key?

I ask this because I want to know if server performance is affected when using multiple session variables (e.g. large objects in a session and many users), to know if keys of objects that will not be used will no longer be beneficial in memory usage server, and also knows what happens under the hood when these keys are deleted.

+4
source share
1 answer

From my basic understanding, when you assign a variable to a session key, it will either save its pointer (when it is a reference type) or its field (when it is a value type, since you store a shared object in the session), thereby creating a copy of it.

, , .Remove(), , ?

, . , GC.

, , (, ), , , , , .

, . ( GC, ) , , , ).

Session , Hashtable, , Session - - , . , , - , , , , , , . , , 1 , , .

+2

All Articles