Release idle memory to the central cache
| 237 | |
| 238 | // Release idle memory to the central cache |
| 239 | void ThreadCache::Scavenge() { |
| 240 | // If the low-water mark for the free list is L, it means we would |
| 241 | // not have had to allocate anything from the central cache even if |
| 242 | // we had reduced the free list size by L. We aim to get closer to |
| 243 | // that situation by dropping L/2 nodes from the free list. This |
| 244 | // may not release much memory, but if so we will call scavenge again |
| 245 | // pretty soon and the low-water marks will be high on that call. |
| 246 | //int64 start = CycleClock::Now(); |
| 247 | for (int cl = 0; cl < kNumClasses; cl++) { |
| 248 | FreeList* list = &list_[cl]; |
| 249 | const int lowmark = list->lowwatermark(); |
| 250 | if (lowmark > 0) { |
| 251 | const int drop = (lowmark > 1) ? lowmark/2 : 1; |
| 252 | ReleaseToCentralCache(list, cl, drop); |
| 253 | |
| 254 | // Shrink the max length if it isn't used. Only shrink down to |
| 255 | // batch_size -- if the thread was active enough to get the max_length |
| 256 | // above batch_size, it will likely be that active again. If |
| 257 | // max_length shinks below batch_size, the thread will have to |
| 258 | // go through the slow-start behavior again. The slow-start is useful |
| 259 | // mainly for threads that stay relatively idle for their entire |
| 260 | // lifetime. |
| 261 | const int batch_size = Static::sizemap()->num_objects_to_move(cl); |
| 262 | if (list->max_length() > batch_size) { |
| 263 | list->set_max_length( |
| 264 | max<int>(list->max_length() - batch_size, batch_size)); |
| 265 | } |
| 266 | } |
| 267 | list->clear_lowwatermark(); |
| 268 | } |
| 269 | |
| 270 | IncreaseCacheLimit(); |
| 271 | } |
| 272 | |
| 273 | int ThreadCache::FreeList::gListCount = 0; |
| 274 |
nothing calls this directly
no test coverage detected