Resources for Developers

Jemalloc Buildpack

Purpose of this buildpack

Jemalloc is a general purpose malloc implementation that works to avoid memory fragmentation in multithreaded applications. This buildpack makes it easy to install and use jemalloc with your apps.

Set up this buildpack for your application

This buildpack is designed to be used in conjunction with one or more additional buildpacks, thanks to the multi buildpack.

For instance, when creating a new Ruby app on Scalingo:

$ scalingo create my-app
$ scalingo env-set BUILDPACK_URL=https://github.com/Scalingo/multi-buildpack.git

$ cat << EOF > .buildpacks
https://github.com/Scalingo/jemalloc-buildpack.git
https://github.com/Scalingo/ruby-buildpack.git
EOF

The above commands configure your application to use the multi buildpack, and define the .buildpacks file. This file configures the different buildpacks to apply. In this example, we configure the jemalloc and the Ruby buildpack.

Configuration

Set the JEMALLOC_ENABLED config option to true and jemalloc will be used for all commands run inside of your containers.

scalingo env-set JEMALLOC_ENABLED=true

Per Container Type

To control when jemalloc is configured on a per container basis, use jemalloc.sh <cmd> and ensure that JEMALLOC_ENABLED is unset.

Example Procfile:

web: jemalloc.sh bundle exec puma -C config/puma.rb

Choice of jemalloc version

Set this to select or pin to a specific version of jemalloc. The default is to use the latest stable version if this is not set. You will receive an error mentioning tar if the version does not exist.

Default: 5.1.0

note: This setting is only used during app deployment. Changing it will require a code change to be deployed in order to take affect.

scalingo env-set JEMALLOC_VERSION=3.6.0

Available Versions:

  • 3.6.0
  • 4.0.4
  • 4.1.1
  • 4.2.1
  • 4.3.1
  • 4.4.0
  • 4.5.0
  • 5.0.1
  • 5.1.0

mode_edit Suggest edits