473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 1252

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

Similar topics

10
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...
8
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...
4
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...
5
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...
24
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...
1
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...
11
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...
2
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)...
9
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...
87
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.