Graphql: High memory usage ( 500mb, 1gb! )

Created on 2 Feb 2018  路  2Comments  路  Source: graphql-go/graphql

I have a resolver that gets 10.000 records from the db and then return that in the query.

I have a massive use of ram when i call this query ( the object is very small in term of bytes ).

I will attach the complete pprof svg.

pprof009.svg.zip

Here's the code:

var GetAllWorkersReport = &graphql.Field{

    Type:        graphql.NewList(WorkerReport),
    Description: "",
    Resolve: func(p graphql.ResolveParams) (interface{}, error) {

        start := time.Now()

        var res []*workers.WorkerReport
        stream, err := rpc.Workers().GetWorkersReport(context.Background(), &workers.None{})

        if err != nil {
            log.Println("[ERROR]", err.Error())
            return nil, err
        }

        for {

            rcv, err := stream.Recv()
            if err != nil {
                if err != io.EOF {
                    return nil, err
                }
                break
            }

            // if len(res) < 200 {
            res = append(res, rcv)
            // }
        }

        util.TimeTrack(start, "Stream finished")

        return res, nil
    },
}

screen shot 2018-02-02 at 15 04 22

Most helpful comment

Are you running against the latest version of the graphql package? I believe these issues are fixed now.

All 2 comments

Are you running against the latest version of the graphql package? I believe these issues are fixed now.

@Kliton - can you confirm if this has been resolved?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jiharal picture jiharal  路  5Comments

titanous picture titanous  路  3Comments

tobyjsullivan picture tobyjsullivan  路  5Comments

conord33 picture conord33  路  6Comments

amedeiros picture amedeiros  路  3Comments