TooBiased
TooBiased

Reputation: 11

Fractured Memory Pages during Memory Allocation?

My current situation is the following: I am allocating tbytes with malloc(t) then I fill this memory with data (just to force the mapping from virtual to physical memory). The memory page size is 4kB.

Given this situation, I have the following questions:

1.) How much physical memory is used by this (I see the following options):

2.) Will this continous piece of virtual memory (one allocation) also be mapped to a continous piece of physical memory?

3.) If there is some waste, can I measure the exact memory footprint of my application? preferably from inside C++.

I should note, that currently my code runs on a ubuntu linux machine, but insights into other systems would still be welcome.

Upvotes: 1

Views: 73

Answers (1)

I-V
I-V

Reputation: 753

    • First of all the memory allocations are always rounded (up) to page size.
    • I didn't understand what you said "while allocation exists"...
    • Although it can cause many problems, every thread in your process who has a pointer to the allocated memory can access it (so you need to synchronize those threads etc.
  1. You have already got an answer.
  2. You can use mmap

Upvotes: 1

Related Questions