You could try increasing your heap space by passing -Xmx and -Xms command line arguments, for example, -Xmx1024m -Xms1024m
If it uses more than a GB then you likely have a problem.
What OS are you? There should be a file named either gradlew (for bash based terminals) or gradlew.bat (for windows terminals) that you can use, and gradle should set itself up when you first run it. For example...
./gradlew.bat build