pcp
[Top] [All Lists]

Re: [pcp] memory leak in PCP::PMDA

To: Jason Rappleye <jason.rappleye@xxxxxxxx>
Subject: Re: [pcp] memory leak in PCP::PMDA
From: nathans@xxxxxxxxxx
Date: Sun, 1 Aug 2010 09:48:39 +1000 (EST)
Cc: pcp@xxxxxxxxxxx
In-reply-to: <690336291.32071280619938432.JavaMail.root@xxxxxxxxxxxxxxxxxx>
Sender: nscott@xxxxxxxxxx
----- "Jason Rappleye" <jason.rappleye@xxxxxxxx> wrote:

> Hi,

Hi Jason,

> I found a memory leak when using metrics of type PM_TYPE_STRING in a 
> perl PMDA. I tracked the problem down to PMDA.xs:fetch_callback, which
> populates atom->cp by calling strdup with the string returned from the
> fetch callback. Unfortunately, the memory allocated here by strdup is 
> never freed.

*nod*

> This might be a bit of a hack, but I'm not knowledgeable enough about 
> XS to propose a different solution. If someone else has a better idea,
> by all means, please speak up :-)

Yeah, thats fine - there is a way to free it, by making the saved string
global and also testing/freeing it in the fetch routine after pmdaFetch.
I've tweaked your patch to do that & committed it to dev branch.  Oh and
also made a version change to 1.09 for that interface (from 1.08) so you
can tell which package has the fix (will go out in pcp 3.4 I'd expect).

cheers.

-- 
Nathan

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [pcp] memory leak in PCP::PMDA, nathans <=