cancel
Showing results for 
Search instead for 
Did you mean: 

perform gc per .z.pg

mklee
New Contributor
Given that we cant use -g 1 and no change on caller side,
is there any way to perform gc upon each .z.pg?
 
I initially have
.z.pg:{ bigresult: value x; .Q.gc[]; bigresult };

but the memory is not going down until next smaller query.
1 ACCEPTED SOLUTION

rocuinneagain
Contributor II
Contributor II

Is there a reason you cannot use -g 1 ?

 

Running .Q.gc[] so often is not the best approach but if you needed to a timer could check and run if after .z.pg for you:

 

runGC:0b
.z.pg:{ bigresult: value x;runGC::1b; bigresult };
.z.ts:{if[runGC;.Q.gc[];runGC::0b]}
\t 1

 

 

https://code.kx.com/q/ref/dotz/#zts-timer 

To run it less often you could set a threshold and in the if statement check memory usage

https://code.kx.com/q/ref/dotq/#qw-memory-stats 

View solution in original post

1 REPLY 1

rocuinneagain
Contributor II
Contributor II

Is there a reason you cannot use -g 1 ?

 

Running .Q.gc[] so often is not the best approach but if you needed to a timer could check and run if after .z.pg for you:

 

runGC:0b
.z.pg:{ bigresult: value x;runGC::1b; bigresult };
.z.ts:{if[runGC;.Q.gc[];runGC::0b]}
\t 1

 

 

https://code.kx.com/q/ref/dotz/#zts-timer 

To run it less often you could set a threshold and in the if statement check memory usage

https://code.kx.com/q/ref/dotq/#qw-memory-stats