File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ func (b *Batch) Push(record interface{}) error {
46
46
if err := b .pushHandler (batch ); err != nil {
47
47
return err
48
48
}
49
+
50
+ // dereference batch to clue GC, unless user wants to retain data
51
+ batch = nil
49
52
} else {
50
53
b .itemsToSave [b .batchPosition ] = record
51
54
b .batchPosition ++
@@ -63,7 +66,9 @@ func (b *Batch) Flush() error {
63
66
subSlice := (b .itemsToSave )[0 :b .batchPosition ]
64
67
b .itemsToSave = make ([]interface {}, b .batchSize , b .batchSize )
65
68
b .batchPosition = 0
66
- return b .flushHandler (subSlice )
69
+ err := b .flushHandler (subSlice )
70
+ subSlice = nil
71
+ return err
67
72
}
68
73
69
74
return nil
Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ func (w *Worker) start() {
90
90
w .jobErrorFn (job , & w .workerContext , err )
91
91
}
92
92
93
+ // nil out data to clue GC
94
+ w .workerContext .Data = nil
95
+
93
96
_ , _ = w .logFn ("worker%d: completed %s!\n " , w .id , job .Name )
94
97
case <- w .quitChan :
95
98
_ , _ = w .logFn ("worker%d stopping\n " , w .id )
You can’t perform that action at this time.
0 commit comments