How does Elasticsearch automatically configure heap size based on available memory?

Hi I just setup an Elasticsearch 7.14 cluster with 2 nodes. I was about to configure JVM Heap size and saw this message

The heap size is automatically configured by Elasticsearch ## based on the available memory in your system and the roles ## each node is configured to fulfill. If specifying heap is ## required, it should be done through a file in jvm.options.d, ## and the min and max should be set to the same value. For ## example, to set the heap to 4 GB, create a new file in the ## jvm.options.d directory containing these lines:

How does this work? Does it assume that the server is only for Elasticsearch?

Because in the same EC2 I use other applications and I don't want huge proportion of the memory to go to Elasticsearch. I would normally give 4GB of ram for heap(each node). The machine has a total capacity of 60GBs.

I would say that it will assume that only elasticsearch will run on the server as this is recommended, it is based on the total server memory and it won't take in consideration other services running on the server.

If you are running other services in the same machine then you should manually set the heap.