github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/server/status/runtime_jemalloc_darwin.go (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  // +build !stdmalloc,darwin
    12  
    13  package status
    14  
    15  // extern void je_zone_register();
    16  import "C"
    17  
    18  func init() {
    19  	// On macOS, je_zone_register is run at init time to register jemalloc with
    20  	// the system allocator. Unfortunately, all the machinery for this is in a
    21  	// single file, and is not referenced elsewhere, causing the linker to omit
    22  	// the file's symbols. Manually force the presence of these symbols on macOS
    23  	// by explicitly calling this method.
    24  	//
    25  	// Note that the same could be achieved via linker flags, but go >= 1.9.4
    26  	// requires explicit opt-in for the required flag, which we want to avoid
    27  	// having to put up with.
    28  	//
    29  	// See https://github.com/jemalloc/jemalloc/issues/708 and the references
    30  	// within.
    31  	C.je_zone_register()
    32  }