Mercurial > hg > svcore
comparison system/System.cpp @ 1401:cc62d7862203
Some bits and bobs to do with handling memory pressure
author | Chris Cannam |
---|---|
date | Mon, 06 Mar 2017 17:23:46 +0000 |
parents | 39271c98cbdd |
children | 91231350ee22 |
comparison
equal
deleted
inserted
replaced
1400:d2ecf0acc3e2 | 1401:cc62d7862203 |
---|---|
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 } | |
183 | 201 |
184 return; | 202 return; |
185 | 203 |
186 #else | 204 #else |
187 #ifdef __APPLE__ | 205 #ifdef __APPLE__ |