From 92be964b654ebce27a8edf2a3ae90d3a822c95d6 Mon Sep 17 00:00:00 2001 From: GeorgeC Date: Fri, 1 Nov 2024 17:12:33 -0400 Subject: [PATCH] Add MemoryCheck service for monitoring max heap memory --- Dockerfile | 2 +- .../avillach/dictionary/memory/MemoryCheck.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/main/java/edu/harvard/dbmi/avillach/dictionary/memory/MemoryCheck.java diff --git a/Dockerfile b/Dockerfile index 457f53e..d0dc7bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,4 +26,4 @@ ENV DATASOURCE_USERNAME=${DATASOURCE_USERNAME} ENV SPRING_PROFILE=${SPRING_PROFILE} # Default to no profile -ENTRYPOINT java $DEBUG_VARS $PROXY_VARS -Xmx8192m -jar /dictionary.jar --spring.profiles.active=${SPRING_PROFILE:-} \ No newline at end of file +ENTRYPOINT java $DEBUG_VARS $PROXY_VARS -Xmx8192m ${JAVA_OPTS} -jar /dictionary.jar --spring.profiles.active=${SPRING_PROFILE:-} \ No newline at end of file diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/memory/MemoryCheck.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/memory/MemoryCheck.java new file mode 100644 index 0000000..5af223b --- /dev/null +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/memory/MemoryCheck.java @@ -0,0 +1,15 @@ +package edu.harvard.dbmi.avillach.dictionary.memory; + +import jakarta.annotation.PostConstruct; +import org.springframework.stereotype.Service; + +@Service +public class MemoryCheck { + + @PostConstruct + public void checkMemory() { + long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024); + System.out.println("Max Heap Memory (Xmx): " + maxMemory + " MB"); + } + +}