Hi Simon, Primary difference here is stack allocated vs heap allocated storage location for managed pointer. Stack allocated storage location of managed pointer has known lifetime which is bound to the stack frame. When managed pointer stored in stack allocated storage location it should be considered reachable (and therefore isn't collectable) while the current stack position is lower than the address of the storage location. If storage location for managed pointer is heap allocated then there is no such clear condition for checking reachable-ness of it, therefore gcroot is required.
-Valery. -----Original Message----- From: Simon Robinson [mailto:[EMAIL PROTECTED]] Sent: Friday, April 12, 2002 2:59 PM To: [EMAIL PROTECTED] Subject: [DOTNET] gcroot for arguments and locals MC++ won't allow you to declare a managed pointer as a member of an unmanaged class, but requires you to use gcroot<> instead. However declaring a managed pointer as a local variable in a function or as an argument to a function in an unmanaged class does NOT produce a compilation error, and there's no word in the docs about using gcroot here. I'm assuming you are still supposed to use gcroot<> in all managed pointer declarations - can anyone confirm if that is correct? Simon You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.