You should definitely extend the memory for the Compute Engine, 512MB is too little. 1GB should be considered a very minimal value for this component (this is what I use on my laptop test instance).
If you don’t have sufficient memory on your SonarQube server, you can temporarily reduce the memory allocated to the Web component to 512MB.
I can’t really comment on your search engine heap settings without the size of the SonarQube indices.