The problem here is unmarshalling the entire groups array. It causes massive heap churn. Filter at the source or use json.RawMessage for nested objects.
type AggregateEvent struct {
Groups []json.RawMessage `json:"groups"`
}
- gc_event_schema
- go_json_rawmessage
- heap_allocation