How to force daemons deletion

Hello Gradle Forums,

Im having the following issue while using Gradle 6.3 (Gradle --version output below):


Gradle 6.3

Build time: 2020-03-24 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60

Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant™ version 1.10.7 compiled on September 1 2019
JVM: 11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OS: Linux 5.4.0-42-generic amd64

The problem that I’m facing right now, is that everytime I run gradle for an SpringBoot application with the following configuration:

org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Even when the process finishes, my RAM memory is still used, I have: 16 Gb, so after 3 re-runs (I don’t mean 3 different services, just the same one stopped, and re-run again…) consumes 12 Gb and if I run another one it starts to fulfill the Swap memory (976M) making my entire system to lag.

I’ve tried deleting the gradle configurations as before, but sometimes I get the error below:
Stackoverflow post so if someone could give me a better advice to upgrade my tunning configurations I would be glad to read them too, but I still think that this tunning problem isn’t really the problem, because sometimes it works well, but it still doesn’t free the RAM after execution, and daemon stopped.

What I want to know if there is some way to force Gradle to dispose memory or force kill the daemons, instead of waiting until they get automatically erased (because sometimes after 30 min, my RAM isn’t free yet). Even if I run gradle --stop it stops the daemons but the memory isn’t released. Is there something like gradle --force-kill-daemons ?

I hope I’ve made myself clear and would be glad if you could send me the Documentation links or where I can find more information related to this.

Pages where I’ve been looking:
Gradle issue memory consumption Linux
Stopped daemons don’t dispose memory

Someone has this figured out? I still haven’t solved it, so any help is welcome! Thanks!