You may get more traction asking in the communities that exist for those tools: IntelliJ and Docker
8GB for two separate IntelliJ projects sounds low. You could try importing both into one instance as separate "modules" so that there is only one IntelliJ instance/window.
Depending on how you are running the VM, the host may be choking it through the host OS and leading to OOM. Especially with a tool like docker.
Edit: I see you commented usage of windows, you may need to look into wslconfig