Aikar's Flags Calculator
Give it your server's allocated RAM. It hands back the exact java command to paste into your Startup Command field, with Xms and Xmx already set and headroom already left below your container limit.
Full reasoning (why headroom, why equal Xms/Xmx, when to skip this) is in the optimization guide. This page just does the arithmetic.
Startup Command
Headroom covers metaspace, thread stacks, and GC overhead beyond the heap, not extra server capacity. 1 GB is enough for a vanilla-plus-perf-mods setup; heavy modpacks load more classes and off-heap buffers, so this bumps it to 2 GB. Source and full flag-by-flag explanation: PaperMC docs.