pcp
[Top] [All Lists]

[pcp] libpcp_pmda: Fixed a memory leak detected by valgrind. (#21)

To: performancecopilot/pcp <pcp@xxxxxxxxxxxxxxxxxx>
Subject: [pcp] libpcp_pmda: Fixed a memory leak detected by valgrind. (#21)
From: marcliangma7 <notifications@xxxxxxxxxx>
Date: Fri, 15 May 2015 14:14:15 -0700
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=github.com; h=from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe; s=s20150108; bh=pOTypsWsnB7OfKpEtE8p12UN/LM=; b=BqetWSFr7aBvPx5W p4FY6iLz2ktdz3HJg8nVFYwuIFjtIIjrQydHwaRap6mcRjz5JCvDnQ+3JSDpHVh7 2Vv4FLEFLBgsKfsQPAesPQZIWDwmf4ubxBjc3xP8EFvbksjMl/M9k40m0bRrygvo ydMsQXGE9l8OjBTUdXXcXtwRekg=
List-archive: https://github.com/performancecopilot/pcp
List-id: performancecopilot/pcp <pcp.performancecopilot.github.com>
List-post: <mailto:reply+00bd08b6579551acd78824a5625836fc73872a3aa0fcc98e92cf00000001116e23a792a169ce0494c718@reply.github.com>
List-unsubscribe: <mailto:unsub+00bd08b6579551acd78824a5625836fc73872a3aa0fcc98e92cf00000001116e23a792a169ce0494c718@reply.github.com>, <https://github.com/notifications/unsubscribe/AL0Itm9WSIz7qd5x6NKOzFMESVOaf1jhks5oJlkngaJpZM4EcK1r>
Reply-to: performancecopilot/pcp <reply+00bd08b6579551acd78824a5625836fc73872a3aa0fcc98e92cf00000001116e23a792a169ce0494c718@xxxxxxxxxxxxxxxx>

Original issue created at: #19

pmdaproc has memory leaks using the following python monitor client to collect process list at 1 second interval.

/proc/pmdaproc_pid/smaps: (Heap size hits 18Mb after 5 days run)
02416000-035a1000 rw-p 00000000 00:00 0 [heap]
Size: 17964 kB
Rss: 17852 kB
Pss: 17852 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 17852 kB
Referenced: 17852 kB
Anonymous: 17852 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me ac

Valgrind output:

0x42
1
Leak_DefinitelyLost

615,463 bytes in 25,293 blocks are definitely lost in loss record 65 of 65
615463
25293



0x4C2741D
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
malloc


0x505C48D
/usr/local/lib/libpcp.so.3
__pmDecodeNameList

/home/ec2-user/pcp/src/libpcp/src
p_pmns.c
344


0x4E38277
/usr/lib64/libpcp_pmda.so.3
__pmdaMainPDU
/home/ec2-user/pcp/src/libpcp_pmda/src
mainloop.c
201


0x4E386D7
/usr/lib64/libpcp_pmda.so.3
pmdaMain
/home/ec2-user/pcp/src/libpcp_pmda/src
mainloop.c
428


0x402CA6
/var/lib/pcp/pmdas/proc/pmdaproc
main
/home/ec2-user/pcp/src/pmdas/linux_proc
pmda.c
3153


Python client used to repro the issue:

#!/usr/bin/python

from cpmapi import PM_TYPE_U32, PM_TYPE_FLOAT, PM_TYPE_STRING, PM_TYPE_U64
from pcp import pmapi

import json
import sys
import time

class Prototype(object):

def __init__(self):
    self.context = None
    self.opts = pmapi.pmOptions()
    self.opts.pmSetShortOptions("V?")
    self.opts.pmSetLongOptionHeader("Options")
    self.opts.pmSetLongOptionVersion()
    self.opts.pmSetLongOptionHelp()

def execute(self):
    metrics = ('proc.psinfo.pid', 'proc.psinfo.cmd', 'proc.psinfo.nice')
    pmids = self.context.pmLookupName(metrics)
    descs = self.context.pmLookupDescs(pmids)
    result = self.context.pmFetch(pmids)
    process_list = []
    for inst in range(result.contents.get_numval(0)):
        pid_value = self.context.pmExtractValue(
                    result.contents.get_valfmt(0),
                    result.contents.get_vlist(0, inst),
                    descs[0].contents.type, descs[0].contents.type)
        pid =  pid_value.ull
        process_list.append(pid)

    self.context.pmFreeResult(result)
    print json.dumps(process_list)

def connect(self):
    self.context = pmapi.pmContext.fromOptions(self.opts, sys.argv)

if name == 'main':
testApp = Prototype()
testApp.connect()
while True:
testApp.execute()
time.sleep(1)


You can view, comment on, or merge this pull request online at:

  https://github.com/performancecopilot/pcp/pull/21

Commit Summary

  • libpcp_pmda: Fixed a memory leak detected by valgrind.

File Changes

Patch Links:


Reply to this email directly or view it on GitHub.

<Prev in Thread] Current Thread [Next in Thread>