diff options
| author | Mike Hommey <mh@glandium.org> | 2014-06-10 09:18:22 (GMT) |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2014-06-10 14:18:29 (GMT) |
| commit | 6f533c1903a1d067dacfca2f06c6cc9754fdf67e (patch) | |
| tree | 0f1be9fe2f01839206c538d612545a4abcf8a5e8 /src | |
| parent | 5921ba7b0c3b3278c54d569dee37deab2768b70b (diff) | |
| download | jemalloc-6f533c1903a1d067dacfca2f06c6cc9754fdf67e.zip jemalloc-6f533c1903a1d067dacfca2f06c6cc9754fdf67e.tar.gz jemalloc-6f533c1903a1d067dacfca2f06c6cc9754fdf67e.tar.bz2 | |
Ensure the default purgeable zone is after the default zone on OS X
Diffstat (limited to 'src')
| -rw-r--r-- | src/zone.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -176,6 +176,7 @@ register_zone(void) * register jemalloc's. */ malloc_zone_t *default_zone = malloc_default_zone(); + malloc_zone_t *purgeable_zone = NULL; if (!default_zone->zone_name || strcmp(default_zone->zone_name, "DefaultMallocZone") != 0) { return; @@ -237,22 +238,37 @@ register_zone(void) * run time. */ if (malloc_default_purgeable_zone != NULL) - malloc_default_purgeable_zone(); + purgeable_zone = malloc_default_purgeable_zone(); /* Register the custom zone. At this point it won't be the default. */ malloc_zone_register(&zone); - /* - * Unregister and reregister the default zone. On OSX >= 10.6, - * unregistering takes the last registered zone and places it at the - * location of the specified zone. Unregistering the default zone thus - * makes the last registered one the default. On OSX < 10.6, - * unregistering shifts all registered zones. The first registered zone - * then becomes the default. - */ do { default_zone = malloc_default_zone(); + /* + * Unregister and reregister the default zone. On OSX >= 10.6, + * unregistering takes the last registered zone and places it + * at the location of the specified zone. Unregistering the + * default zone thus makes the last registered one the default. + * On OSX < 10.6, unregistering shifts all registered zones. + * The first registered zone then becomes the default. + */ malloc_zone_unregister(default_zone); malloc_zone_register(default_zone); + /* + * On OSX 10.6, having the default purgeable zone appear before + * the default zone makes some things crash because it thinks it + * owns the default zone allocated pointers. We thus unregister/ + * re-register it in order to ensure it's always after the + * default zone. On OSX < 10.6, there is no purgeable zone, so + * this does nothing. On OSX >= 10.6, unregistering replaces the + * purgeable zone with the last registered zone above, i.e the + * default zone. Registering it again then puts it at the end, + * obviously after the default zone. + */ + if (purgeable_zone) { + malloc_zone_unregister(purgeable_zone); + malloc_zone_register(purgeable_zone); + } } while (malloc_default_zone() != &zone); } |
