How objects are stored in the session?

M

mirek

Hi,
I'd like to know how session variables are stored in the session. I if
put a object to the session and then get it back, is this the same
object or a new copy of it? The session holds references to the objects
or eg. serialized byte stream?

What about garbage collecting if the object lives in some moment only in
session? There is no references in code to that object and the GC can
remove the object.

I'd like to know it because I try to put my objects that are wrappers to
unmanaged code to the session and don't know if is it safe. So far it
works OK but maybe I'm only lucky now.

TIA

Regards,
mirek
 
M

Marina

If you are using InProc session state, then it will be the actual reference
to the object. If you are using one of the other models, it will be
serialized and deserialized.

While the session is alive, the object in session will not be garbage
collected. Once the session expires, it becomes eligible for garbage
collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top