Mercurial > hg > svcore
comparison system/System.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 | cc62d7862203 |
children | c7e68755c7ec |
comparison
equal
deleted
inserted
replaced
1404:d40246df828b | 1405:91231350ee22 |
---|---|
178 available = ssize_t(size); | 178 available = ssize_t(size); |
179 | 179 |
180 size = wtotal / 1048576; | 180 size = wtotal / 1048576; |
181 if (size > INT_MAX) size = INT_MAX; | 181 if (size > INT_MAX) size = INT_MAX; |
182 total = ssize_t(size); | 182 total = ssize_t(size); |
183 | |
184 // In 32-bit addressing mode we can't address more than 4Gb. | |
185 // If the total memory is reported as more than 4Gb, we should | |
186 // reduce the available amount by the difference between 4Gb | |
187 // and the total. This won't give us an accurate idea of the | |
188 // amount of memory available any more, but it should be enough | |
189 // to prevent us from trying to allocate more for our own use | |
190 // than can be addressed at all! | |
191 if (sizeof(void *) < 8) { | |
192 if (total > 4096) { | |
193 ssize_t excess = total - 4096; | |
194 if (available > excess) { | |
195 available -= excess; | |
196 } else { | |
197 available = 0; | |
198 } | |
199 } | |
200 } | |
201 | 183 |
202 return; | 184 return; |
203 | 185 |
204 #else | 186 #else |
205 #ifdef __APPLE__ | 187 #ifdef __APPLE__ |