[PATCH] Don't register jemalloc's zone allocator if something else already replaced the system default zone
Mike Hommey
mh+jemalloc at glandium.org
Mon Oct 22 23:42:48 PDT 2012
From: Mike Hommey <mh at glandium.org>
---
src/zone.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/zone.c b/src/zone.c
index cde5d49..c62c183 100644
--- a/src/zone.c
+++ b/src/zone.c
@@ -171,6 +171,16 @@ void
register_zone(void)
{
+ /*
+ * If something else replaced the system default zone allocator, don't
+ * register jemalloc's.
+ */
+ malloc_zone_t *default_zone = malloc_default_zone();
+ if (!default_zone->zone_name ||
+ strcmp(default_zone->zone_name, "DefaultMallocZone") != 0) {
+ return;
+ }
+
zone.size = (void *)zone_size;
zone.malloc = (void *)zone_malloc;
zone.calloc = (void *)zone_calloc;
@@ -241,7 +251,7 @@ register_zone(void)
* then becomes the default.
*/
do {
- malloc_zone_t *default_zone = malloc_default_zone();
+ default_zone = malloc_default_zone();
malloc_zone_unregister(default_zone);
malloc_zone_register(default_zone);
} while (malloc_default_zone() != &zone);
--
1.7.10.4
More information about the jemalloc-discuss
mailing list