Kapacitor High Memory Usage

am using Kapacitor and InfluxDB on the same box. I am running around 12 tick scripts for alert generation with 12 subscriptions across 5 databases. I have total 297 measurements but only 5-6 are used in TICk script for alert generation. Average points written are 4.5K per second.

I am using n1standard8 box from GCP to run this with 8 core and 30G RAM. InfluxDB takes around 10G of RAM average, but Kapacitor goes crazy with almost 20-22G and then crash out.

Following is the one of TICK script -

var data = stream

| from()

  .measurement ( measurememt1)

 .groupby( 'tag1','tag2','tag3')

|where( lambda: cond1 )

|where(lambda: cond2)

|eval (lambda : “field1”)

     .as( 'value')

var alert1 = data

|where( lambda: “tag1” == “someval1” )

|alert()

.crit(lambda: "value" == "somefailed" )

.id("xxxxx")

.details("xxx")

.email("[someemail1@company.com](mailto:someemail1@company.com)")

.log()

var alert2 = data

|where( lambda: “tag1” == “someval2” )

|alert()

.crit(lambda: "value" == "somefailed" )

.id("xxxxx")

.details("xxx")

.email("[someemail2@company.com](mailto:someemail2@company.com)")

.log()

var alert13= data

|where( lambda: “tag1” == “someval3” )

|alert()

.crit(lambda: "value" == "somefailed" )

.id("xxxxx")

.details("xxx")

.email("[someemail3@company.com](mailto:someemail3@company.com)")

.log()

Am writing bad tickscript to make kapacitor crazy to eat memory ? please guide . Will making use of windows node bring down this consumption. I am afraid because it might miss some real points which needs to be alerted.