diff --git a/tools/profiler/core/memory_hooks.cpp b/tools/profiler/core/memory_hooks.cpp index 7b5df524f0ea..3b93f09fe466 100644 --- a/tools/profiler/core/memory_hooks.cpp +++ b/tools/profiler/core/memory_hooks.cpp @@ -584,7 +584,7 @@ void enable_native_allocations(int aMainThreadId) { // with the memory hook machinery, as the bloat log creates its own // allocations. This means we can re-enter inside the bloat log machinery. At // this time, the bloat log does not know about cannot handle the native - // allocation feature. For now just disable the feature. + // allocation feature. // // At the time of this writing, we hit this assertion: // IsIdle(oldState) || IsRead(oldState) in Checker::StartReadOp() @@ -602,11 +602,13 @@ void enable_native_allocations(int aMainThreadId) { // #11: NS_LogCtor // #12: profiler_get_backtrace() // ... - if (!PR_GetEnv("XPCOM_MEM_BLOAT_LOG")) { - EnsureBernoulliIsInstalled(); - EnsureAllocationTrackerIsInstalled(); - ThreadIntercept::EnableAllocationFeature(aMainThreadId); - } + MOZ_ASSERT(!PR_GetEnv("XPCOM_MEM_BLOAT_LOG"), + "The bloat log feature is not compatible with the native " + "allocations instrumentation."); + + EnsureBernoulliIsInstalled(); + EnsureAllocationTrackerIsInstalled(); + ThreadIntercept::EnableAllocationFeature(aMainThreadId); } // This is safe to call even if native allocations hasn't been enabled. diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 60bf7a3f94d5..b3c196e9fe94 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -214,6 +214,18 @@ static uint32_t AvailableFeatures() { #endif #if !defined(MOZ_TASK_TRACER) ProfilerFeature::ClearTaskTracer(features); +#endif +#if defined(MOZ_REPLACE_MALLOC) && defined(MOZ_PROFILER_MEMORY) + if (getenv("XPCOM_MEM_BLOAT_LOG")) { + // The memory hooks are available, but the bloat log is enabled, which is + // not compatible with the native allocations tracking. See the comment in + // enable_native_allocations() (tools/profiler/core/memory_hooks.cpp) for + // more information. + ProfilerFeature::ClearNativeAllocations(features); + } +#else + // The memory hooks are not available. + ProfilerFeature::ClearNativeAllocations(features); #endif if (!JS::TraceLoggerSupported()) { ProfilerFeature::ClearJSTracer(features);