Thanks for your follow-up!
The flat memory usage you’re observing on the Linux-based App Service Plan is expected. When garbage collection (GC) runs in Java (or other runtimes), it frees up unused memory within the JVM, but that memory is not immediately released back to the OS. Instead, it stays allocated for future use, which is why you see memory usage remaining flat even after function execution.
For Java Function Apps, here are some recommendations:
- Choose the right GC and use
G1GC
(default), or considerZGC
for low-latency needs. - You can Set fixed heap sizes: e.g.,
-Xms512m -Xmx1024m
to keep memory predictable. - Enable GC logging it helps analyse memory behaviour (
-Xlog:gc*
). - Enable Always On it Improves performance and avoids cold starts.
- Use performance flags Like
-XX:+TieredCompilation
and-XX:+AlwaysPreTouch
.
These steps could help you manage memory more efficiently, even if the OS metrics don’t show immediate drops in usage. Hope this helps. Do let us know if you have any further queries.
If this answers your query, do click Accept Answer and Yes for "Was this answer helpful." And if you have any further questions, let us know.