When heap is shrinking ptmalloc tries to be smart and uses mmap to change
page protection, which causes the pages to be droped, which causes problems if we don't deregister the pages first. Since memory is cheap in this case (it is still usable, should ptmalloc2 want it back, and is limited in size), we just mprotect the pages instead. This solves the dropping pages problem, and doesn't cause even more calls into the cache code. Thanks to Gleb Natapov for both finding the problem and giving a fix. This should go to the v1.0 branch This commit was SVN r8732.
Этот коммит содержится в:
родитель
d657052510
Коммит
17197666bf
@ -614,10 +614,8 @@ grow_heap(h, diff) heap_info *h; long diff;
|
||||
new_size = (long)h->size + diff;
|
||||
if(new_size < (long)sizeof(*h))
|
||||
return -1;
|
||||
/* Try to re-map the extra heap space freshly to save memory, and
|
||||
make it inaccessible. */
|
||||
if((char *)MMAP((char *)h + new_size, -diff, PROT_NONE,
|
||||
MAP_PRIVATE|MAP_FIXED) == (char *) MAP_FAILED)
|
||||
|
||||
if(mprotect((char *)h + new_size, -diff, PROT_NONE) != 0)
|
||||
return -2;
|
||||
/*fprintf(stderr, "shrink %p %08lx\n", h, new_size);*/
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user