Search code examples
c++pointersmemorysizediskspace

C++ pointer showing impossible memory location


I made a C++ variable and printed its address and it came out to be very large: 0x7ffdf584da2c.
My code is as follows:

#include <iostream>
using namespace std;
int main()
{
    int var = 10;
    cout << "value: " << var << " address: " << &var << endl;
    return 0;
}


value: 10 address: 0x7ffec6f111c4

This type of Hexadecimal memory address (0x7ffdf584da2c) looks impossible as its Decimal comes out to be (140728722577964) which is fairly large for my laptop.
I've a dual boot laptop with Windows 10 and Ubuntu and Memory around 500 GB. The code is written in Ubuntu.


Solution

  • It's fine.

    Computers in 2020 are very complicated. Your process gets a virtual address space whose maximum "slot" will almost certainly exceed the size of the actual RAM on your system (and page file).