c++ - Relationship between dwPageSize and dwAllocationGranularity -


i’m reading google’s tcmalloc source code (the windows porting).

int getpagesize()  {     static int pagesize = 0;     if (pagesize == 0)      {       system_info system_info;       getsysteminfo(&system_info);       pagesize = std::max(system_info.dwpagesize, system_info.dwallocationgranularity);     }     return pagesize;  } 

as can se in code snippet above pagesize(that unit of allocation) calculated max between dwpagesize , dwallocationgranularity. mean know kind of relationship between these 2 values: necessary calculate value in way here upside explicated? , there situations in dwpagesize greater dwallocationgranularity?

disclaimer: answer not based on documentation on interpretation of these constants.

i assume page size correctly reported. assume allocation granularity refers granularity of os memory allocation interface.

there these 2 cases consider:

  • the allocation granularity greater page size. allocating memory block of size of page lead larger allocation of resources, should prevented.

  • the allocation granularity less page size. allocating memory block of size of allocation granularity still lead whole page being allocated/mapped, should prevented.

basically both cases cause os allocate more memory requested. using maximum can avoided, such (user space) allocation code can (relatively) actual memory usage.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -