Addressing to variables and pointers

time stamp -> 00:02:44
in static memory allocation addressing is done at compile time so what if we run the program at another machine?
or even after restarting the machine?

@immanishbainsla
If you run it on a different machine , then you will have to compile it on that machine as well before running it.
If you restart your own machine after compiling , the runnable file with the extension .exe ( in windows ) or .out (in Linux or Mac ) stays there only. It is not deleted so you can run that. Since it is already compiled , the memory is already allocated.

if i have to recompile it before running it on another machine then compilation is meaningless bcz “.exe” files are required to be generated only once like other windows apps i.e. they are not interpreted.

and if you assign memory before then what if the memory is in use at the time of running that particular “.exe” file?

what i mean to say is “what if compiler only decides the amount of memory required to run the program in static memory, and rest if required from Dynamic/Heap memory”?

your quote : “Since it is already compiled , the memory is already allocated.” so what if i compiles many programs that takes more memory than RAM so acc to you compiler won’t compile my programs?

@immanishbainsla

  1. Compilation is necessary. You cannot run the files without compiling. If you run it on other machine , you have to compile it again on that machine.
  2. The memory is already assigned to that particular file and hence it will not be a problem.
  3. If you compile multiple such programs that exceeds the limit of even your RAM , even still your computer will arrange. It may use the concept of ‘virtual memory’ that you may have studied about in the subject ‘Operating Systems’. Do not worry , your computer will still manage. However , running all of these programs will be another problem since your computer may not have enough computation power. You will need a lot of CPUs and GPUs to run all these programs simultaneously which overflow even your RAM limit. Memory won’t be a problem in this situation , execution will be.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.