I would now like to see how these instructions allocate memory.
For example, what if I received the code:
x = new int[5];
y = new int[5];
If they stand out the way it looks in RAM? Is a whole block reserved for each of the variables or blocks (a memory page, or as you call it - 4 KB in size by 32 bits) is divided into 2 variables?
I could not find the answer to my question in any manual. Thanks for all the answers.
I found on Wikipedia: Internal page fragmentation It is rarely required that processes require the use of the exact number of pages. As a result, the last page is likely to be only partially filled, losing some memory. Larger page sizes clearly increase potential memory loss in this way, as more potentially unused portions of memory are loaded into main memory. Smaller page sizes provide a closer match to the actual amount of memory required for distribution. As an example, suppose a page size of 1024 KB. If a process allocates 1025 KB, two pages must be used, resulting in 1023 KB of unused space (where one page consumes 1024 KB completely and the other only 1 KB).
And that was the answer to my question. Thanks anyway guys.
source
share