My question relates to the old technology. Yet it matters a lot to me to get a thorough answer. Could a Visual Basic expert answer me or include links to other sites and sheds light on this memory usage question please? I believe that I had not drafted my question clearly enough in my previous posting.
Consider the following VB 6 code in a custom COM plus object on a page on an e-commerce site:
Dim globalArray(30, 100000)
'Assign long and short strings to the globalArray elements.
'Also some of the elements of globalArray hold smaller arrays. And also load the xml:
Set objGlobalDom = CreateObject("msxml2.FreeThreadedDomDocument.6.0")
objGlobalDom.loadXML (xmlStr)
Application.lock
Set Application("objGlobalDom") = objGlobalDom
Application("globalArray") = globalArray
Application.unlock
With any new session the following variable assignments are done:
set Session("objGlobalDom") = Application("objGlobalDom")
session("globalArray") = Application("objGlobalDom")
Let's suppose that the Application("objGlobalDom")
will contain an xml with some 1000 nodes and each node takes about 3k of memory. Let’s say the array will take some 50 meg of memory.
Considering VB6 and COM object:
I understand that each instance of the object references the object’s data.
What I don’t understand is:
Ifsession("objGlobalDom"
) does not contain a copy of theapplication("objGlobalDom")
, why changes in the data ofsession("objGlobalDom")
are not automatically reflected in the data ofapplication("objGlobalDom")
? Is the reference ofsession("objGlobalDom")
toApllication("globalDom")
only for reading the data ofApplication("objGlobalDom")
?According to Microsoft, in a situation such as my
globalArray
example, thesession("globalArray")
always gets a copy of theApplication("globalArray")
and so Microsoft discourages assigning the array to session variables. But it is not clear to me that in the case of COM object and object reference, does the assignment ofset Session("objGlobalDom") = Application("objGlobalDom")
copies the array to the session variable?