My friend and I built a mod pack and are playing together, but I am having some issues which appeared after playing on the server for a collective of 20 hours.
So I'm trying to fix up/adjust my JVM arguments. Basically what is happening is I am experiencing hard lag spikes every few seconds caused by the mem hitting 100% in the F3 debug menu. I monitored the usage and the GC is clearing up memory, but does so at inconsistent intervals and is never able to keep up with the memory usage/consumption. My friend who has an equal system to mine has 0 issues when we play on his server. We use the same JVM argument, and I've even tried more complex ones, and still have the same issue.
I have 16G of RAM (soon to be 32G). IDK what other system info you may need, but I run Windows 10, and i7 core. If you need more details, let me know. (F3 screenshot is attached)
Try resetting the JVM arguments; the ones that you are using are only good for old versions which were much less memory-hungry and "CMSIncrementalMode" in particular is all but useless and probably harmful on modern systems (it was designed for single-core CPUs, and Java 8+ even gives a warning when you use it as it will be removed in a newer version of Java); the following are the default arguments; only change "Xmx2G" as needed, this uses the "G1" garbage collector, which was designed for memory-intensive programs like modern Minecraft and limits the maximum pause time to 50 ms (CMS does require less overhead, which is why I use it myself, minus the incremental mode option, instead of the default arguments but it can't handle extreme allocation rates). Also, setting Xmn to a high value is even worse since garbage collecting the "new" generation is very expensive and it should be as small as possible (the old JVM arguments set it to 128M while the current ones don't set it at all):