473,614 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stack-based Memory Questions

Hello

I am reading up a bit on how memmory is used in the .NET Framework and have a few question
about the stack-based approach

* I understand that the stack is used to provide a layer of abstractio
between the CLR and the underlaying memory hardware (porting to anothe
architecture should not change the program, i.e you dont work with register
directly)

* I understand that the stack help create variable scope, since it only exist a
long as the defining object (method etc) lives in the stack - once poped the variabl
goes out of scope

* What about the following cod

int a = 1
// ten other calls which is added to the stack, leaving a as the 11t
// stack element
int b = a

Does the stack have to be poped all the way down to the position wher
a is stored, and then push back the stack contents again? I dont see this a
a probable solution which makes me think the stack might support "non traditional
access? Can the CLR read from any stack position (Peek(int frame)) or what

* The same goes for the memory management - the GC looks for active reference
from to the objects on the stack. Does the application roots hold "duplicate information
on references - That is once a reference type is pushed to the stack, it is also assigned t
an application root. And likewize - when a reference type pops of the stack, does th
associated application root get cleared (if so there are there any reference counting bein
done in the root to know that ALL refrences to an objekt on the heap isn't on the stack an
more, so it is not cleared prematurly)

I've read that the stack-based look up should be (slightly) faster then the heap lookups
which means there should be an alterate way of reading the stack (not yourself but fo
the CLR / GC). Of course the stack is local to a thread and the heap is not, so I guess som
kind of locking is needed to ensure the contents of the heap is threadsafe

All and any feedback on this will be a big help

Cheers..
Jul 21 '05 #1
0 1268

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
8326
by: Shuo Xiang | last post by:
Greetings: I know that variables declared on a stack definitely does not reside in heap space so there is only a very limited amount of stuff that you can store in the stack of a function. But what about the global space? Is that the same as the heap space or is that still a form of special stack? Because once I've seen someone declare a 1 megabyte char array in global space like this: char s;
8
2089
by: LedZep | last post by:
What up everyone, I have to write a program that uses a stack to determine whether a string is a palindrome (a string that is spelled identically backward and forward). The program has to ignore spaces, case sensitivity and punctuation. I need three text boxes. The first will be for input of the string. The second will display the string when the "check" button is clicked and the result of the analysis (string is a palindrome or is...
4
2143
by: alisaee | last post by:
plz check what i have made wrong what is requierd her is to creat class queue and class stack and run the push,pop operation . #include<iostream.h> #include<conio.h> #include<stdio.h> class stack { public:
5
2017
by: srikanth | last post by:
is it possible not to decrement the top variable after we remove(or retreive) a file from a stack >MY IDEA is:> if top is not decremented the stack is like it has some files existing in it with the top most file empty >i.e, something like hiding the files by one step (or one position of stack) >i.e,if someone tries to extract the top most file he see's that it is empty thus assumes the stack to be empty. >can this view be applied...
24
2854
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as are structs, where classes are on the heap... when value types go out of scope the memory is re- allocated, object remain in memory waiting to be cleaned up by the garbage collector, etc, but he responded 'so why not just put say a class on the...
1
4209
by: alfie27 | last post by:
I currently have a working program that is a stack that stores integers. Now i have to convert it to store strings instead of integers. I have been working on this for hours and just keep getting errors of all kinds. I have decided to start from scratch. Any suggestions someone can give me would be greatly appreciated!! Here is the current code: #include <iostream> using std::cout; using std::cin; #include <cstring> using std::strcpy;
11
1773
by: tom | last post by:
Hi! Im new to Python and doing exercise found from internet. It is supposed to evaluate expression given with postfix operator using Stack() class. class Stack: def __init__(self): self.items = def push(self, item): self.items.append(item)
2
1630
by: AZRebelCowgirl73 | last post by:
I have casted the stack so that it will print however now it does print like required however it includes un-needed stuff! (Point2D.Double) (Point 2D.Double) (Point2D.Double) (Point2D.Double) (Point2D.Double) Is there a way to take the and the Point2D.Double out so that it reads just the () and the number, number? Also is there a way to shorten the first double so that it is only two spaces long after the decimal? Thanks! Here are...
9
2503
by: Tarique | last post by:
Hello all.I am trying to implement a stack which can store either integer or float values. The code is given below: #include<stdio.h> #include<stdlib.h> #include<string.h> #define STACKSIZE 100
87
5518
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first place? I can see two definite disadvantages with this: 1) deeply nested recursive calls to a function (especially if it defines
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8287
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.