Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
1404:d40246df828b | 1405:91231350ee22 |
---|---|
95 GetRealMemoryMBAvailable(memoryFree, memoryTotal); | 95 GetRealMemoryMBAvailable(memoryFree, memoryTotal); |
96 | 96 |
97 SVDEBUG << "StorageAdviser: disc space: " << discFree | 97 SVDEBUG << "StorageAdviser: disc space: " << discFree |
98 << "M, memory free: " << memoryFree | 98 << "M, memory free: " << memoryFree |
99 << "M, memory total: " << memoryTotal << "M" << endl; | 99 << "M, memory total: " << memoryTotal << "M" << endl; |
100 | |
101 // In 32-bit addressing mode we can't address more than 4Gb. | |
102 // If the total memory is reported as more than 4Gb, we should | |
103 // reduce the available amount by the difference between 4Gb | |
104 // and the total. This won't give us an accurate idea of the | |
105 // amount of memory available any more, but it should be enough | |
106 // to prevent us from trying to allocate more for our own use | |
107 // than can be addressed at all! | |
108 if (sizeof(void *) < 8) { | |
109 if (memoryTotal > 4096) { | |
110 ssize_t excess = memoryTotal - 4096; | |
111 if (memoryFree > excess) { | |
112 memoryFree -= excess; | |
113 } else { | |
114 memoryFree = 0; | |
115 } | |
116 SVDEBUG << "StorageAdviser: more real memory found than we " | |
117 << "can address in a 32-bit process, reducing free " | |
118 << "estimate to " << memoryFree << "M accordingly" << endl; | |
119 } | |
120 } | |
121 | |
100 SVDEBUG << "StorageAdviser: disc planned: " << (m_discPlanned / 1024) | 122 SVDEBUG << "StorageAdviser: disc planned: " << (m_discPlanned / 1024) |
101 << "K, memory planned: " << (m_memoryPlanned / 1024) << "K" << endl; | 123 << "K, memory planned: " << (m_memoryPlanned / 1024) << "K" << endl; |
102 SVDEBUG << "StorageAdviser: min requested: " << minimumSize | 124 SVDEBUG << "StorageAdviser: min requested: " << minimumSize |
103 << "K, max requested: " << maximumSize << "K" << endl; | 125 << "K, max requested: " << maximumSize << "K" << endl; |
104 | 126 |