Cbq-engine for memory and cpu question

when I use N1QL, cbq-engine process use RAM is increasing,but when I disconnect client, the cbq-engine use RAM is always high, and the cpu will periodically up to 100%,how can I solve?

Which version are you using?
Memory allocations behavior comes from garbage collection that happens over time and is not immediate. Query execution engine also has background threads manage these operations like garbage collection. I expect that you may see cpu utilization even when queries aren’t running due to these background activities.

I try to modify the code in https://github.com/couchbase/query/blob/master/server/http/service_response.go.
In function ‘Execute’ and end of the function,I use this.stopAndClose(state) to replace this.Close() , the RAM can decrease for over a period of time,I guess when some server error state, the request not close,the memory always not to GC.Is this possible?

for my test picture, this server just have query service.

this is n1ql request,

and the cpu picture,
but some time cpu up to 100%,I use top to look process is cbq-engine

and last the RAM picture:

the process can GC,but RAM always is high. before another test, the RAM use keep 70%.

for my solution:
cancel two function:

  1. Do not listen the request to disconnect

code link

closeNotify := resp.(http.CloseNotifier).CloseNotify()
closeNotifier := func() {
select {
case <-closeNotify:
case <-rv.requestNotify:
go closeNotifier()

the requests/s increase 20 times In my system environment,for my environment the request normal can’t disconnect.

  1. cancel request log

code link

accounting.LogRequest(acctstore, request_time, service_time, request.resultCount,
request.resultSize, request.errorCount, request.warningCount, request.Statement(),
request.SortCount(), request.Prepared(), request.Id().String())