java memory optimization

-Xms512m

-Xmx512m

-XX:MaxDirectMemorySize=512m

any ?

elasticsearch.yml , jvm.options.d/heap

## IMPORTANT: JVM heap size
################################################################
##
## 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:
##
Xms1024m
-Xmx1024m
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

if docker:

https://docs.docker.com/config/containers/resource_constraints/