Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2007

Tip: Looking for answers? Try searching our database.

Managed and Unmanaged

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Creativ - 31 Oct 2007 22:38 GMT
I'm still confused with managed and unmanaged

In VS2005, in the same project with /CLR switch on.

in managed.h
ref class ManagedClass
{
}

in unmanaged.h
class UnmanagedClass
{
}

in Main.cpp
{
   ManagedClass^ mc = gcnew ManagedClass; // So this is managed
   UnmanagedClass umc;
}

My question is with UnmanagedClass umc; // So this creates a unmanaged
object, on the unmanaged heep? Does that mean all unmanged objects
won't be moved around by GC? (I assume yes since they are on unmanaged
heap).

Is there good reading describing this?
William DePalo [MVP VC++] - 31 Oct 2007 23:21 GMT
> I'm still confused with managed and unmanaged

OK.

> In VS2005, in the same project with /CLR switch on.
>
[quoted text clipped - 16 lines]
> My question is with UnmanagedClass umc; // So this creates a unmanaged
> object, on the unmanaged heep?

No. Unmanaged heap allocation requires that you use new. As you have written
it, umc resides on the stack.

> Does that mean all unmanged objects won't be moved
> around by GC?

Using C++/CLI, only objects allocated via gcnew reside on the managed heap.
The garbage collector only ever moves or collects objects on the managed
heap. Native objects are untouched.

Regards,
Will

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.