Skip to content

Commit

Permalink
Explicitly Set MALLOC_ARENA_MAX
Browse files Browse the repository at this point in the history
Because the JVM isn't very aware of the memory model of the OS that it's
running on, it would often request memory in a way that caused a large number
of malloc arenas, especially under a full heap.  Unfortunately, it would not
use the malloc arena count in it's internal accounting of it's current memory
usage, causing the container to kill the process.  This change fixes the
number of arenas, taking the performance hit for better behavior at the edge
of a container.

[resolves #550]
  • Loading branch information
nebhale committed Feb 12, 2018
1 parent 75b6e73 commit d1a21ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/java_buildpack/jre/open_jdk_like_memory_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def memory_calculation_command
end

# (see JavaBuildpack::Component::BaseComponent#release)
def release; end
def release
@droplet.environment_variables.add_environment_variable 'MALLOC_ARENA_MAX', 2
end

protected

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@
component.compile
end

it 'adds MALLOC_ARENA_MAX to environment' do
component.release

expect(environment_variables).to include('MALLOC_ARENA_MAX=2')
end

end

0 comments on commit d1a21ff

Please sign in to comment.