@@ -62,16 +62,16 @@ type group struct {
62
62
63
63
var (
64
64
isLibpfmInitialized = false
65
- libpmfMutex = sync.Mutex {}
65
+ libpfmMutex = sync.Mutex {}
66
66
)
67
67
68
68
const (
69
69
groupLeaderFileDescriptor = - 1
70
70
)
71
71
72
72
func init () {
73
- libpmfMutex .Lock ()
74
- defer libpmfMutex .Unlock ()
73
+ libpfmMutex .Lock ()
74
+ defer libpfmMutex .Unlock ()
75
75
pErr := C .pfm_initialize ()
76
76
if pErr != C .PFM_SUCCESS {
77
77
klog .Errorf ("unable to initialize libpfm: %d" , int (pErr ))
@@ -266,10 +266,12 @@ func readPerfEventAttr(name string, pfmGetOsEventEncoding func(string, unsafe.Po
266
266
func pfmGetOsEventEncoding (name string , perfEventAttrMemory unsafe.Pointer ) error {
267
267
event := pfmPerfEncodeArgT {}
268
268
fstr := C .CString ("" )
269
+ defer C .free (unsafe .Pointer (fstr ))
269
270
event .fstr = unsafe .Pointer (fstr )
270
271
event .attr = perfEventAttrMemory
271
272
event .size = C .ulong (unsafe .Sizeof (event ))
272
273
cSafeName := C .CString (name )
274
+ defer C .free (unsafe .Pointer (cSafeName ))
273
275
pErr := C .pfm_get_os_event_encoding (cSafeName , C .PFM_PLM0 | C .PFM_PLM3 , C .PFM_OS_PERF_EVENT , unsafe .Pointer (& event ))
274
276
if pErr != C .PFM_SUCCESS {
275
277
return fmt .Errorf ("unable to transform event name %s to perf_event_attr: %d" , name , int (pErr ))
@@ -409,8 +411,8 @@ func (c *collector) Destroy() {
409
411
410
412
// Finalize terminates libpfm4 to free resources.
411
413
func Finalize () {
412
- libpmfMutex .Lock ()
413
- defer libpmfMutex .Unlock ()
414
+ libpfmMutex .Lock ()
415
+ defer libpfmMutex .Unlock ()
414
416
415
417
klog .V (1 ).Info ("Attempting to terminate libpfm4" )
416
418
if ! isLibpfmInitialized {
0 commit comments