I’m reading the 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 you can se in the code snippet above pagesize
(that is the unit of allocation) is calculated as the max between dwPageSize and dwAllocationGranularity.
What I mean to know is the kind of relationship between these two values: is it necessary to calculate the value in the way here upside explicated? And are there any situations in which dwPageSize could be greater than dwAllocationGranularity?