Skip to content

Commit 12c4a51

Browse files
committed
chore: release bpf object memory
These are the two references to the BPF object read from the file. Both need to be set to nil for the Go garbage collector to reclaim the memory.
1 parent ce3f1bb commit 12c4a51

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.22.4
77
require (
88
github.com/IBM/fluent-forward-go v0.2.2
99
github.com/Masterminds/sprig/v3 v3.2.3
10-
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d
10+
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca
1111
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689
1212
github.com/aquasecurity/tracee/signatures/helpers v0.0.0-20240607205742-90c301111aee
1313
github.com/aquasecurity/tracee/types v0.0.0-20240607205742-90c301111aee

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdII
404404
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
405405
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
406406
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
407-
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d h1:+CNq6qH8KW9n9JQt4vnaKM03PilwkVEPAsrjQDKeXno=
408-
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d/go.mod h1:UpO6kTehEgAGGKR2twztBxvzjTiLiV/cb2xmlYb+TfE=
407+
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca h1:OPbvwFFvR11c1bgOLhBq1R5Uk3hwUjHW2KfrdyJan9Y=
408+
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca/go.mod h1:UpO6kTehEgAGGKR2twztBxvzjTiLiV/cb2xmlYb+TfE=
409409
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689 h1:mAOehSHrqAZ4lvn3AYgDxn+aDTKrv81ghNnGlteDB00=
410410
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689/go.mod h1:km0QNkaoOVxU/IYF/Pw/ju/2SO1mYn+HJOIyMDtnfkE=
411411
github.com/aquasecurity/tracee/signatures/helpers v0.0.0-20240607205742-90c301111aee h1:1KJy6Z2bSpmKQVPShU7hhbXgGVOgMwvzf9rjoWMTYEg=

pkg/cmd/tracee.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func (r Runner) Run(ctx context.Context) error {
5353
},
5454
)
5555

56+
// Need to force nil to allow the garbage
57+
// collector to free the BPF object
58+
r.TraceeConfig.BPFObjBytes = nil
59+
5660
// Initialize tracee
5761

5862
err = t.Init(ctx)

pkg/ebpf/tracee.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,10 @@ func (t *Tracee) initBPF() error {
13921392
return errfmt.WrapError(err)
13931393
}
13941394

1395+
// Need to force nil to allow the garbage
1396+
// collector to free the BPF object
1397+
t.config.BPFObjBytes = nil
1398+
13951399
// Populate eBPF maps with initial data
13961400

13971401
err = t.populateBPFMaps()

0 commit comments

Comments
 (0)