MemoryTracking enables peak memory tracking during evaluation with an optional set of types.MemoryTrackerOption values to configure the tracker's size calculator, sample interval, and limit behaviors. Peak memory is measured in aggregate element counts as computed by a types.SizeCalculator and is o
(memOpts ...types.MemoryTrackerOption)
| 945 | // attributes, call results, constructed aggregates, and comprehension results. The peak |
| 946 | // watermark is available via the EvalDetails.PeakMemory() method. |
| 947 | func MemoryTracking(memOpts ...types.MemoryTrackerOption) ProgramOption { |
| 948 | return func(p *prog) (*prog, error) { |
| 949 | p.memoryOptions = append(p.memoryOptions, memOpts...) |
| 950 | p.evalOpts |= OptTrackMemory |
| 951 | return p, nil |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | // MemoryLimit enables memory tracking and configures program evaluation to exit early with a |
| 956 | // "memory limit exceeded" error if the peak tracked memory exceeds the limit. |
no outgoing calls