<pedrocorreia.net ⁄>
 

<C# Heap(ing) Vs Stack(ing) in .NET: Part I ⁄ >




clicks: 1049 1049 2007-01-27 2007-01-27 goto programacao myNews programacao  Bookmark This Bookmark This


Even though with the .NET framework we don't have to actively worry about memory management and garbage collection (GC), we still have to keep memory management and GC in mind in order to optimize the performance of our applications. Also, having a basic understanding of how memory management works will help explain the behavior of the variables we work with in every program we write. In this article I'll cover the basics of the Stack and Heap, types of variables and why some variables work as they do.

There are two places the .NET framework stores items in memory as your code executes. If you haven't already met, let me introduce you to the Stack and the Heap. Both the stack and heap help us run our code. They reside in the operating memory on our machine and contain the pieces of information we need to make it all happen.

Stack vs. Heap: What's the difference?

The Stack is more or less responsible for keeping track of what's executing in our code (or what's been "called"). The Heap is more or less responsible for keeping track of our objects (our data, well... most of it - we'll get to that later.).

Think of the Stack as a series of boxes stacked one on top of the next. We keep track of what's going on in our application by stacking another box on top every time we call a method (called a Frame). We can only use what's in the top box on the stack. When we're done with the top box (the method is done executing) we throw it away and proceed to use the stuff in the previous box on the top of the stack. The Heap is similar except that its purpose is to hold information (not keep track of execution most of the time) so anything in our Heap can be accessed at any time. With the Heap, there are no constraints as to what can be accessed like in the stack. The Heap is like the heap of clean laundry on our bed that we have not taken the time to put away yet - we can grab what we need quickly. The Stack is like the stack of shoe boxes in the closet where we have to take off the top one to get to the one underneath it.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory0112200...




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

RouterJs: easy routing for your ajax Web applications

RouterJs is a simple router for your ajax web apps. It's build upon History.js which means that Rout (...)

clicks: 100 100 2012-05-14 2012-05-14 goto url (new window) haithembelhaj.g... goto myNews programacao


Backbone computed properties

This gist shows one way to implement read- and write-enabled computed properties on a Backbone Model (...)

clicks: 114 114 2012-05-13 2012-05-13 goto url (new window) https://gist.gi... goto myNews programacao


Create Instagram Filters With PHP

In this tutorial, I'll demonstrate how to create vintage (just like Instagram does) photos with PHP (...)

clicks: 110 110 2012-05-12 2012-05-12 goto url (new window) net.tutsplus.co... goto myNews programacao


HTML5 jQuery Paint Plugin

Websanova Paint is a HTML5 canvas based jQuery plugin. It allows you to free paint on a canvas area (...)

clicks: 103 103 2012-05-12 2012-05-12 goto url (new window) websanova.com/t... goto myNews programacao


Android Query

Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI el (...)

clicks: 111 111 2012-05-12 2012-05-12 goto url (new window) code.google.com... goto myNews programacao


Real-time Applications With Node.js and Socket.IO

Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for th (...)

clicks: 112 112 2012-05-11 2012-05-11 goto url (new window) codingcookies.c... goto myNews programacao


Sass vs. LESS vs. Stylus: Preprocessor Shootout

CSS3 preprocessors are languages written for the sole purpose of adding cool, inventive features to (...)

clicks: 117 117 2012-05-11 2012-05-11 goto url (new window) net.tutsplus.co... goto myNews programacao


15 Handpicked jQuery Drop Down Menus Tutorials

Here we are presenting another brilliant collection of 15 jQuery navigation menu that you can downlo (...)

clicks: 125 125 2012-05-10 2012-05-10 goto url (new window) smashingapps.co... goto myNews programacao