So basically when I play on a modified minecraft client there are some freezes(or lags) caused by memory garbage collection. I found that it's caused my mgc using lagometer (large orange spikes). They occur for no apparent reason without any frequency at the time when the memory involved tries to exceed the limits of allocated memory. I was trying to find the reason for lags using the mod LagGoggles but did not reveal anything. Often there are a blue spikes exactly after orange spike on the plot.
Minecraft 1.12.2 with forge and optifine, 22 mods, 3gb ram memory avaliable for javaw.