Skip to content

Commit

Permalink
chore: release bpf object memory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rscampos committed Jul 29, 2024
1 parent ce3f1bb commit 300cc58
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.4
require (
github.com/IBM/fluent-forward-go v0.2.2
github.com/Masterminds/sprig/v3 v3.2.3
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689
github.com/aquasecurity/tracee/signatures/helpers v0.0.0-20240607205742-90c301111aee
github.com/aquasecurity/tracee/types v0.0.0-20240607205742-90c301111aee
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdII
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d h1:+CNq6qH8KW9n9JQt4vnaKM03PilwkVEPAsrjQDKeXno=
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240715144951-c8f76d124d7d/go.mod h1:UpO6kTehEgAGGKR2twztBxvzjTiLiV/cb2xmlYb+TfE=
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca h1:OPbvwFFvR11c1bgOLhBq1R5Uk3hwUjHW2KfrdyJan9Y=
github.com/aquasecurity/libbpfgo v0.7.0-libbpf-1.4.0.20240729111821-61d531acf4ca/go.mod h1:UpO6kTehEgAGGKR2twztBxvzjTiLiV/cb2xmlYb+TfE=
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689 h1:mAOehSHrqAZ4lvn3AYgDxn+aDTKrv81ghNnGlteDB00=
github.com/aquasecurity/tracee/api v0.0.0-20240613134034-89d2d4fc7689/go.mod h1:km0QNkaoOVxU/IYF/Pw/ju/2SO1mYn+HJOIyMDtnfkE=
github.com/aquasecurity/tracee/signatures/helpers v0.0.0-20240607205742-90c301111aee h1:1KJy6Z2bSpmKQVPShU7hhbXgGVOgMwvzf9rjoWMTYEg=
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/tracee.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (r Runner) Run(ctx context.Context) error {
},
)

// Need to force nil to allow the garbage
// collector to free the BPF object
r.TraceeConfig.BPFObjBytes = nil

// Initialize tracee

err = t.Init(ctx)
Expand Down
4 changes: 4 additions & 0 deletions pkg/ebpf/tracee.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,10 @@ func (t *Tracee) initBPF() error {
return errfmt.WrapError(err)
}

// Need to force nil to allow the garbage
// collector to free the BPF object
t.config.BPFObjBytes = nil

// Populate eBPF maps with initial data

err = t.populateBPFMaps()
Expand Down

0 comments on commit 300cc58

Please sign in to comment.