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 / C# / March 2008

Tip: Looking for answers? Try searching our database.

Whats difference between stack and heap in C#?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
COHENMARVIN@lycos.com - 11 Mar 2008 16:59 GMT
I'm reading that the stack is where 'value' types are created, and the
heap is where reference objects are allocated but I'm wondering if
these are just 2 arbitrary sections of memory, or there is more to it.
Also on a somewhat related topic, in C++ I've read that a DLL is in a
separate section of memory with its own variables.  Is this true also
in C#?  If you have 10 assemblies all calling the same DLL, where are
the 10 copies of the DLL variables kept?  And what is the relationship
between DLL and assemblies?  Is a DLL just a module in an assembly?
Thanks,
Marvin
Jon Skeet [C# MVP] - 11 Mar 2008 17:05 GMT
On Mar 11, 3:59 pm, COHENMAR...@lycos.com wrote:
> I'm reading that the stack is where 'value' types are created, and the
> heap is where reference objects are allocated but I'm wondering if
> these are just 2 arbitrary sections of memory, or there is more to it.

Well, there's slightly more to it - and there's certainly more to it
than "value types go on the stack" but broadly speaking you only need
to worry about stack vs heap.

It can be argued (http://csharpindepth.com/ViewNote.aspx?NoteID=41)
that you shouldn't care even that far. That sounds okay until your
stack overflows :)

> Also on a somewhat related topic, in C++ I've read that a DLL is in a
> separate section of memory with its own variables.  Is this true also
> in C#?  If you have 10 assemblies all calling the same DLL, where are
> the 10 copies of the DLL variables kept?  And what is the relationship
> between DLL and assemblies?  Is a DLL just a module in an assembly?

There aren't 10 different copies - there'll just be the one, assuming
you've only got a single AppDomain.

A DLL is usually a whole assembly, not just a module.

Jon

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.