Click here to Skip to main content
15,888,124 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello everyone:

My question relates to the old technology. Yet it matters a lot to me to get a through 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:

Dom 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”)

The Application(“objGlobalDom”) will contain an xml with some 1000 nodes and each node takes about 3k of memory.
The array will take some 50 meg of memory.

Now considering VB6 and COM object:

1- I understand that each instance of the object references the object’s data. What I don’t understand is:
Why changes in the data of session(“objGlobalDom”) are not automatically reflected in the data of application(“objGlobalDom”) if the session(“objGlobalDom”) references the data of Application(“objGlobalDom”)? If the data of session(“objGlobalDom”) is not a copy of the Application(“objGlobalDom”) then what data do we modify in session(“objGlobalDom”) when the changes in the session(“objGlobalDom”) are not reflected in the data of the Application(“objGlobalDom”)?

2- According to Microsoft, in a situation such as my globalArray example, the session(“globalArray”) always gets a copy of the Application(“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 of set Session(“globalArray”) = Application(“globalArray”) copies the array to the session variable?

I really appreciate your answers and thank you in advance for your response.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900