Thread: Confused about Memory

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    oook... i just figured that because if you use an address-of operator of an integer to cout, it sends a hexidecimal value...i guess i just got confused with that...soo that could just be an integer then... gotcha... but why would people do this, instead of just saying 1, 2, 3, 4, 5?

    And when would somebody define a memory location? Or can you?

    And also, I think the questions above are still relevant? Like, how is memory availability predetermined?
    Last edited by gL_nEwB; 06-17-2006 at 11:17 AM.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Memory availability isn't predetermined. No memory addresses are defined on the compilation of a program. What's defined is merely offsets in memory from the start of the program's memory block. When a program is run, the OS can put it anywhere in memory, so the variables won't have the same addresses, but they will always be the same distance from each other.

    You can't "define" a memory location, because as you said, you'll never know what's available to your program. Yes, all pointers really hold are integers, but it's the fact that it's a pointer that tells the computer it's a memory address. When you get into assembly, you'll see there are different registers for regular data and pointers.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    ahhhh i get ya now... so its like the OS has a memory map sorda... and so does the program itself.... but the OS places the program somewhere on it's map...so the program's map is unaffected...just offsetted in memory... but the variable addresses remain parrallel within the program....

    Code:
    Program Orignal Starting Memory: OxFFFFFF
    Program Variable: 0xFFFFFA
    
    Program Starting Memory After OS Movement: 0xFFFFFF + 1(or whatever value to get to the memory specified on the OS map)
    Program Variable After OS Movement: 0xFFFFFA + 1(or whatever value to get to the memory specified on the OS map)
    So its like saying that the OS controls Global Addresses? And the program controls local addresses that are just offsets of the Global Addresses?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM
  2. Replies: 4
    Last Post: 01-13-2008, 02:14 AM
  3. Copying memory, pointers and the like.
    By psychopath in forum C++ Programming
    Replies: 34
    Last Post: 12-12-2006, 01:37 PM
  4. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  5. Memory leak trackers
    By Darkness in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-30-2004, 02:03 PM