Mercurial > hg > svcore
diff base/StorageAdviser.cpp @ 1405:91231350ee22
Change where the 32-bit memory calculation adjustment is carried out -- more transparent here
author | Chris Cannam |
---|---|
date | Tue, 07 Mar 2017 13:27:53 +0000 |
parents | adbd16d2c1e8 |
children | 48e9f538e6e9 |
line wrap: on
line diff
--- a/base/StorageAdviser.cpp Tue Mar 07 13:27:31 2017 +0000 +++ b/base/StorageAdviser.cpp Tue Mar 07 13:27:53 2017 +0000 @@ -97,6 +97,28 @@ SVDEBUG << "StorageAdviser: disc space: " << discFree << "M, memory free: " << memoryFree << "M, memory total: " << memoryTotal << "M" << endl; + + // In 32-bit addressing mode we can't address more than 4Gb. + // If the total memory is reported as more than 4Gb, we should + // reduce the available amount by the difference between 4Gb + // and the total. This won't give us an accurate idea of the + // amount of memory available any more, but it should be enough + // to prevent us from trying to allocate more for our own use + // than can be addressed at all! + if (sizeof(void *) < 8) { + if (memoryTotal > 4096) { + ssize_t excess = memoryTotal - 4096; + if (memoryFree > excess) { + memoryFree -= excess; + } else { + memoryFree = 0; + } + SVDEBUG << "StorageAdviser: more real memory found than we " + << "can address in a 32-bit process, reducing free " + << "estimate to " << memoryFree << "M accordingly" << endl; + } + } + SVDEBUG << "StorageAdviser: disc planned: " << (m_discPlanned / 1024) << "K, memory planned: " << (m_memoryPlanned / 1024) << "K" << endl; SVDEBUG << "StorageAdviser: min requested: " << minimumSize