473,387 Members | 3,750 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,387 software developers and data experts.

Memory Location

Is it possible to practically see the memory location stored in a
variable? For e.g. consider the statement

Dim myInt As Integer = 10

If I am not wrong, the memory location allocated to "myInt" would
store the value of 10. Is it possible to see where exactly has the
memory been allocated & what is the value at that memory location?

I doubt if I have expressed myself lucidly.....I am asking this
question in the hope that it would help me understand reference
types.....right now, I am getting too confused after going through a
plethora of articles on reference types....

Thanks,

Ron

Oct 16 '07 #1
4 1669
You could likely with a low level debugger but I'm not sure this would help
to grasp the concepts.

You could start by :
- Keep in mind (but only for a short period of time !) that a variable name
is just a "symbol" for a memory location
- For a value type, the value is stored at this memory location.
- For a reference type, the value stored at this location is the location
(i.e. a pointer or a "reference") of the actual object.

Now as precisely the goal of a variable is to keep us away from having to
deal with the concept of memory locations, we'll simply say that the value
is stored "in" the variable and the variable name is thought as the value
that is stored at this location (rather than its location itself).

This is perhaps where the confusion could arise.

Hoping to decrease rather than to increase your confusion...
--
Patrice
..
<rn**@rediffmail.coma écrit dans le message de news:
11*********************@i38g2000prf.googlegroups.c om...
Is it possible to practically see the memory location stored in a
variable? For e.g. consider the statement

Dim myInt As Integer = 10

If I am not wrong, the memory location allocated to "myInt" would
store the value of 10. Is it possible to see where exactly has the
memory been allocated & what is the value at that memory location?

I doubt if I have expressed myself lucidly.....I am asking this
question in the hope that it would help me understand reference
types.....right now, I am getting too confused after going through a
plethora of articles on reference types....

Thanks,

Ron

Oct 16 '07 #2
On Oct 16, 7:19 am, "Patrice" <http://www.chez.com/scribe/wrote:
You could likely with a low level debugger but I'm not sure this would help
to grasp the concepts.

You could start by :
- Keep in mind (but only for a short period of time !) that a variable name
is just a "symbol" for a memory location
- For a value type, the value is stored at this memory location.
- For a reference type, the value stored at this location is the location
(i.e. a pointer or a "reference") of the actual object.

Now as precisely the goal of a variable is to keep us away from having to
deal with the concept of memory locations, we'll simply say that the value
is stored "in" the variable and the variable name is thought as the value
that is stored at this location (rather than its location itself).

This is perhaps where the confusion could arise.

Hoping to decrease rather than to increase your confusion...

--
Patrice
.
<r...@rediffmail.coma écrit dans le message de news:
1192534945.797481.51...@i38g2000prf.googlegroups.c om...
Is it possible to practically see the memory location stored in a
variable? For e.g. consider the statement
Dim myInt As Integer = 10
If I am not wrong, the memory location allocated to "myInt" would
store the value of 10. Is it possible to see where exactly has the
memory been allocated & what is the value at that memory location?
I doubt if I have expressed myself lucidly.....I am asking this
question in the hope that it would help me understand reference
types.....right now, I am getting too confused after going through a
plethora of articles on reference types....
Thanks,
Ron- Hide quoted text -

- Show quoted text -
Patrice, it has indeed been very nice of you to help me grasp the
topic of reference types. Thanks for the same. However I am extremely
sorry to confess that your answer has further compounded my
confusions.

I guess I need a break, think peacefully about it & come afresh
tomorrow with a fresh mind....so see you tomorrow......

Ron

Oct 16 '07 #3
Was afraid of that as I was not sure what caused the confusion.

The thing you'll see most often is :
- a variable stores something
- a value type is a type whose data are stored directly by this variable
- a reference type is a type whose data are stored as a reference (a
pointer) to the actual data

For example an integer will be directly stored in the variable (this is a
value type).
On the other hand an object (whose size can vary much, that have methods
etc...) is actually a reference (a pointer) on the actual data that allows
to implements such a behavior.
I wanted to mention that a variable name is basically itself an alias for a
storage location thinking that it could be what caused this confusion...

Hopefully it will be clearer over time - perhaps not thanks to me, sorry
;-)

--
Patrice

<rn**@rediffmail.coma écrit dans le message de news:
11**********************@i13g2000prf.googlegroups. com...
On Oct 16, 7:19 am, "Patrice" <http://www.chez.com/scribe/wrote:
[cut]

Patrice, it has indeed been very nice of you to help me grasp the
topic of reference types. Thanks for the same. However I am extremely
sorry to confess that your answer has further compounded my
confusions.

I guess I need a break, think peacefully about it & come afresh
tomorrow with a fresh mind....so see you tomorrow......

Ron
Oct 16 '07 #4
On Oct 16, 9:31 am, "Patrice" <http://www.chez.com/scribe/wrote:
Was afraid of that as I was not sure what caused the confusion.

The thing you'll see most often is :
- a variable stores something
- a value type is a type whose data are stored directly by this variable
- a reference type is a type whose data are stored as a reference (a
pointer) to the actual data

For example an integer will be directly stored in the variable (this is a
value type).
On the other hand an object (whose size can vary much, that have methods
etc...) is actually a reference (a pointer) on the actual data that allows
to implements such a behavior.

I wanted to mention that a variable name is basically itself an alias fora
storage location thinking that it could be what caused this confusion...

Hopefully it will be clearer over time - perhaps not thanks to me, sorry
;-)

--
Patrice

<r...@rediffmail.coma écrit dans le message de news:
1192543802.977106.176...@i13g2000prf.googlegroups. com...
On Oct 16, 7:19 am, "Patrice" <http://www.chez.com/scribe/wrote:
[cut]

Patrice, it has indeed been very nice of you to help me grasp the
topic of reference types. Thanks for the same. However I am extremely
sorry to confess that your answer has further compounded my
confusions.

I guess I need a break, think peacefully about it & come afresh
tomorrow with a fresh mind....so see you tomorrow......

Ron
Hopefully it will be clearer over time - perhaps not thanks to me, sorry :-)
No...no....you still deserve a lot of thanks for trying so much to
help me understand this. It's my dumb brain which is at fault
actually.

Anyway, a new day..with a fresh mind..am starting to understand slowly
& steadily (after all, slow & steady wins the race!)....now for some
questions to ensure myself that I am starting to understand this...

Are all variables, be they value types or reference types, ALWAYS
stored in the stack? For e.g. consider the following code:

--------------------------------------
Class MyInt
Public MyValue As Integer
End Class

Sub Page_Load(..........)
Dim x As New MyInt
Dim y As New MyInt

x.MyValue = 15
y = x

y.MyValue = 30
Response.Write(x.MyValue)
End Sub
--------------------------------------

"MyInt", being a reference type, resides in the heap. "x" is also a
reference type but it is stored in the stack BUT it refers to the
class "MyInt" in the heap? So does that mean all variables,
irrespective of their types, are stored in the stack?

BTW, does "x" refer to the class "MyInt" or to the variable "MyValue"
in the class "MyInt"? For e.g. note the line

x.MyValue = 15

Does this mean the variable "MyValue" (which is in the heap) is
assigned a value of 15 & "x" just refers to the variable
"MyValue" (whose value is now 15 in the heap)?

Also note the line

y = x

The above line means that "x" & "y" point to the same object "MyInt"
but what about

y.MyValue = x.MyValue

Doesn't the above line mean that "x" & "y" point to the same object?

Thanks,

Ron

Oct 17 '07 #5

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

Similar topics

2
by: shyamal | last post by:
I want to display memory content using C++ on LINUX. For example, the user may ask to display 256 bytes from 0x1000ff00. The problem is , if any location is invalid, the program will coredump...
10
by: fabio de francesco | last post by:
Hi what do you think of the following? Why are we permitted to do that? And why the C++ Library doesn't stop someone willing to perfom that assignement (*a = 20)? #include <iostream> ...
11
by: William Buch | last post by:
I have a strange problem. The code isn't written by me, but uses the qsort function in stdlib. ALWAYS, the fourth time through, the memory location of variable list (i.e. mem location = 41813698)...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
13
by: Samshayam | last post by:
I have come across the application of placement new in memory mapped i/o in a number of books.I am not able to understand it completely, may be becaues of my lack of knowledge with memory mapped...
2
by: gavino | last post by:
REHDAT LINUX 4S PHP 4.3.9 LEGACY APP I MOVED NOW EATS MEMORY CAN ANYONE TAE A LOOK ? I FIXED ONE PARTIALLY BY CHANGING TO here are my apache settings: 1 page laoding for a few seconds eat like...
18
by: MajorSetback | last post by:
I am using the Redhat version of Linux and GNU C++. It is not clear to me whether this is a Linux issue or a C++ issue. I do not have this problem running the same program on Windows but...
20
by: sethukr | last post by:
hi, i need to store a value to a particular memory location without having a variable. So, how can i access a 'memory address' without using variables?? Is it possible in C??? Plz, help...
50
by: arunajob | last post by:
Hi all, If I have a piece of code something like this void main(void) { char * p1="abcdefghijklmn"; ............................................. }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.