10 pts.
 In C++, while accessing the memory with pointers, if it reaches the end of memory what happens?
In C++, while accessing the memory with pointers, if it reaches the end of memory what happens?

Software/Hardware used:
ASKED: June 6, 2008  1:06 PM
UPDATED: June 6, 2008  6:42 PM

Answer Wiki:
In C++ or C, when you allocate memory using malloc or new you are asking for chunk of memory. But Compiler will always assign memory in pages. Now each page contains how many bytes of memory is configurable and system dependant. Whenever you are accessing the memory beyond your assign i.e. one page Segmentation fault will occur. But always keep in mind for each memroy allocation, compiler never allocates one page for each allocation. Consider 1) malloc for 100 bytes then compiler will assign one page (Consider page of 4KB) 2) malloc for 200 bytes then compiler will not asign any page for you but provide addres within same page. This is how memory is allocated by compiler. Now if you access memory beyond your page you will get segmentation fault.
Last Wiki Answer Submitted:  June 6, 2008  6:42 pm  by  12345678988   20 pts.
All Answer Wiki Contributors:  12345678988   20 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _