S
Siegfried Heintze
Would like to pursue some questions I recently encountered in an
interview -- someone might ask them again in another interview. I was not
very satisfied with the answers I gave the interviewer.
(1) Can someone point me to a discussion of the managed stack? Does it work
the same way as the native (CPU Vender implemented) stack with a frame
pointer that is the head of a linked list of stack frames where each time we
enter a function we create a new stack frame in which new variables are
pushed and each time we exit a function the entire stack frame is popped?
(2) Can someone point me to a discussion of the managed heap? How does it
work? Does it use counted pointers like COM often does? What, exactly,
happens when use operator= to (shallow) copy a SqlDataReader object from a
stack local variable to a global variable? How does it prevent memory leaks
that occur in COM when two objects reference each other and keep the others
reference count nonzero? How is the managed heap different than the native
heap? I think the managed heap implements defragmentation automatically like
Java. Does it use the mark and sweep algorithm or some other algorithm.
(3) Why do we have non-determanistic destructors in C#? Asked differently:
Why do some classes, like the SQL data reader, need to have their dispose
function called explicitly? Why did not the language designers implement
deterministic destructors so we would not have to manually use the "using"
statement or (worse yet) manually call the dispose function when the object
goes out of scope? Could not the language designers design the C# language
so the compiler tells runtime: "hey! this sqldatareader is going out of
scope so you better call the dispose function."
(4) Is there any circumstance where I would NOT want to call dispose
(explicitly or via the "using" statement) on function local SQL Data Reader
object when it is going out of scope?
(5) How is the structure of a managed DLL different from a native DLL?
(6) What choices of XML parser implementatoins do I have? I can call the
native MSXML via COM interop or PInvoke and I can the ones in System.Xml.
What is the difference? Is System.XML just a wrapper for MSXML?
(7) What choices of XML parser types are there? There is SAX and DOM. Any
other choices?
(8) What is the difference between using PInvoke to manipulate a semephore
or mutex and using System.Threading?
Thanks,
Siegfried
interview -- someone might ask them again in another interview. I was not
very satisfied with the answers I gave the interviewer.
(1) Can someone point me to a discussion of the managed stack? Does it work
the same way as the native (CPU Vender implemented) stack with a frame
pointer that is the head of a linked list of stack frames where each time we
enter a function we create a new stack frame in which new variables are
pushed and each time we exit a function the entire stack frame is popped?
(2) Can someone point me to a discussion of the managed heap? How does it
work? Does it use counted pointers like COM often does? What, exactly,
happens when use operator= to (shallow) copy a SqlDataReader object from a
stack local variable to a global variable? How does it prevent memory leaks
that occur in COM when two objects reference each other and keep the others
reference count nonzero? How is the managed heap different than the native
heap? I think the managed heap implements defragmentation automatically like
Java. Does it use the mark and sweep algorithm or some other algorithm.
(3) Why do we have non-determanistic destructors in C#? Asked differently:
Why do some classes, like the SQL data reader, need to have their dispose
function called explicitly? Why did not the language designers implement
deterministic destructors so we would not have to manually use the "using"
statement or (worse yet) manually call the dispose function when the object
goes out of scope? Could not the language designers design the C# language
so the compiler tells runtime: "hey! this sqldatareader is going out of
scope so you better call the dispose function."
(4) Is there any circumstance where I would NOT want to call dispose
(explicitly or via the "using" statement) on function local SQL Data Reader
object when it is going out of scope?
(5) How is the structure of a managed DLL different from a native DLL?
(6) What choices of XML parser implementatoins do I have? I can call the
native MSXML via COM interop or PInvoke and I can the ones in System.Xml.
What is the difference? Is System.XML just a wrapper for MSXML?
(7) What choices of XML parser types are there? There is SAX and DOM. Any
other choices?
(8) What is the difference between using PInvoke to manipulate a semephore
or mutex and using System.Threading?
Thanks,
Siegfried