Aerospike Filter and Expressions

I have an aerospike client setup in spring boot Java, and I am trying to query a set with one filter and 2 or more expressions since aerospike does not support multiple secondary index filters.

Now with this setup , when two or more queries are done on the spring boot server, I am getting an error on the java terminal log as - java.lang.OutOfMemoryError: Java heap space.

below is the attached code snippet for the api:

    org.json.JSONObject query = new org.json.JSONObject(filter.get("filter").toString());
    Statement stmt = new Statement();
    System.out.println("Incoming query parameters: "+query);
    QueryPolicy queryPolicy = new QueryPolicy();
    queryPolicy.failOnFilteredOut = true;
    queryPolicy.filterExp =
    RecordSet rs = asClient.query(null, stmt);
    ArrayList output = new ArrayList();
    while ( {
        Record r = rs.getRecord();
    return output;

Can anyone help on this , and state what is going wrong here?

Seems the JVM is unable to allocate more RAM. Maybe the output ArrayList has grown too large?