adoptium / temurin-build

Eclipse Temurin™ build scripts - common across all releases/versions
Apache License 2.0
1.02k stars 249 forks source link

native memory might not be released without setting MALLOC_TRIM_THRESHOLD_ #1518

Open tmancill opened 4 years ago

tmancill commented 4 years ago

Hi AdoptOpenJDK team,

I chatted with some of you at your booth at FOSDEM about a difference in runtime behavior between AdoptOpenJDK 8 and Ubuntu's openjdk-8 with applications that allocate and free lots of native memory. tmancill/nativememory is a repro case that demonstrates the difference and also the work-around that we're using right now, which is to set MALLOC_TRIM_THRESHOLD_. Without this, our JNA-heavy applications end up reaching a cgroup limit and getting OOM'd.

I haven't yet looked into potential differences between the Adopt and Ubuntu builds, but my hunch is that the use case exposes a subtle difference in runtime glibc behavior based on something happening at build time, maybe compiler flags?, version of glibc available at build time?, something else?

We'll keep looking into it, but I wanted to go ahead and raise an issue here based on our conversation and in case it helps anyone else experiencing increased process memory usage when allocating lots of threads that make malloc() and free() calls via JNA.

Thank you, tony

@smlambert, @gdams, @grepory, @kittylyst

karianna commented 4 years ago

I suspect this will be binding against a certain version of glibc.