Re: [collectd] Possible memory leak in python plugin?
hello, it's been couple of weeks since I patched, and there is no memory leak anymore.^^ I've used several tools to detect problems, example, valgrind http://valgrind.org/, memwatch( http://www.linkdata.se/sourcecode/memwatch/) for python test, i used guppy and it told me there was no leak. but couldn't find ways to to detect. because valgrind couldn't track child thread, memwatch doesn't understand free statements sometimes. It was my best way that just checking the candidate source codes line by line. specially embeded python and python c-extension, there might be some missing in reference counting of object in c code. please checkout following nice articles that explains the problem. http://edcjones.tripod.com/refcount.html hope you have lucky. ;) 2012/4/12 Richard Marshall > Hi, > > ** ** > > In this thread it looks like you may have found a memory leak problem in > collectd python, but I’m not sure. I am seeing a memory leak to in a very > similar situation (though using the following plugin: > https://github.com/mleinart/collectd-haproxy . I’m using the Ubuntu > package collectd-core 4.10.1-2. Are you able to confirm if this is an issue > you have detected and resolved, and how I may apply that to my systems?*** > * > > ** ** > > Many Thanks > > ** ** > > Rich > > ** ** > > ** ** > > ** ** > > [image: Description: cid:EBCCB7C5-BE97-454F-95DB-B5CD5BB470CA] > > Richard Marshall, Operations Director > > Address: 170-172 Tower Bridge Road, London SE1 3LS > > Phone:+44 203 465 9259 > > Email: *richard.marsh...@tagman.com* > > Skype: richtagman > > ** ** > > We're currently hiring in London and New York - * > http://www.tagman.com/index.php/careers.html* > > ** ** > > ** ** > > ___ > collectd mailing list > collectd@verplant.org > http://mailman.verplant.org/listinfo/collectd > > -- James.kim(김민석) 010 3266 8040 <>___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
Hi, In this thread it looks like you may have found a memory leak problem in collectd python, but I'm not sure. I am seeing a memory leak to in a very similar situation (though using the following plugin: https://github.com/mleinart/collectd-haproxy . I'm using the Ubuntu package collectd-core 4.10.1-2. Are you able to confirm if this is an issue you have detected and resolved, and how I may apply that to my systems? Many Thanks Rich [cid:image001.png@01CD18A6.575F6600] Richard Marshall, Operations Director Address: 170-172 Tower Bridge Road, London SE1 3LS Phone:+44 203 465 9259 Email: richard.marsh...@tagman.com Skype: richtagman We're currently hiring in London and New York - http://www.tagman.com/index.php/careers.html <>___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
Hey, On Wed, Jan 18, 2012 at 02:22:37AM +0100, Sven Trenkel wrote: > Oh well, I uploaded a patch to github, it should appear in the > official collectd repository soonish. thanks for fixing this, Sven! I've cherry-picked the commit to the collectd-4.10 branch which is available from git.verplant.org and GitHub. Best regards, —octo -- Florian octo Forster Hacker in training GnuPG: 0x0C705A15 http://octo.it/ signature.asc Description: Digital signature ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
As always in life the solution was not as simple as it appeared to be. Oh well, I uploaded a patch to github, it should appear in the official collectd repository soonish. If you want to compile a it yourself from source, this patch should work on the collectd-5.0 branch: http://www.semidefinite.de/collectd-python.patch ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
I am using version 5.0.1 compiled with the spec file included in the sources. I have a single patch applied for summarizing CPU stats, but that's about it. I'm eager to check out your patch. Thanks for looking into this! ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
I am using version 5.0.1 compiled with the spec file included in the sources. I have a single patch applied for summarizing CPU stats, but that's about it. I'm eager to check out your patch. Thanks for looking into this! ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
Never mind, I think I found the bug. I'll test it tomorrow. If you compiled collectd yourself I'll send you a patch if you tell me the exact version number you're using. ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
Re: [collectd] Possible memory leak in python plugin?
What version of collectd are you using? And until we find the cause of this behavior you might try to pull the constant parts of the submitted value out of the for loop. So, v = collectd.Values() v.plugin = 'mongostats' v.type = 'counter' could be put before the loop as it's just creating and destroying the same objects over and over again. This might or might not make the memory leak slower. ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd
[collectd] Possible memory leak in python plugin?
I wrote a simple python reader plugin to collect a few stats from my local mongo server. I noticed that over time, my process would continually grow until it consumed >100MB of memory. If I simply comment out my 'v.dispatch()' function, the memory leak goes away. Is this an issue with collectd, or my code? Also, is there an easier way to differentiate between counters and gauges without adding entries to the TypeDB? Here's a few relevant snippets of my code which executes under collectd's read() callback: def mongostats_getstats(data): # get the delta between the databases' syncedTo counter, and now for x in data['db'].sources.find(): synced_to = x['syncedTo'].as_datetime() now = datetime.datetime.now(utc) delta = now - synced_to total_seconds = ((delta.days * 86400) + delta.seconds) # get the rest of the stats result = data['db'].command('serverStatus') # compile a dictionary of values values = { 'replication_lag': total_seconds, 'connections': result['connections']['current'], 'page_faults': result['extra_info']['page_faults'], 'last_flush_ms': result['backgroundFlushing']['last_ms'], 'insert': result['opcountersRepl']['insert'] \ + result['opcounters']['insert'], 'query': result['opcountersRepl']['query'] \ + result['opcounters']['query'], 'update': result['opcountersRepl']['update'] \ + result['opcounters']['update'], 'delete': result['opcountersRepl']['delete'] \ + result['opcounters']['delete'], 'getmore': result['opcountersRepl']['getmore'] \ + result['opcounters']['getmore'], 'command': result['opcountersRepl']['command'] \ + result['opcounters']['command'] } return values def mongostats_read(data=None): # get stats result = mongostats_getstats(data) # handle the gauge values first for x in ['replication_lag', 'connections', 'last_flush_ms']: v = collectd.Values() v.plugin = 'mongostats' v.type_instance = x v.type = 'gauge' #v.dispatch(values = [result[x]]) # now handle the counters for x in ['page_faults', 'insert', 'query', \ 'update', 'delete', 'getmore', 'command']: v = collectd.Values() v.plugin = 'mongostats' v.type_instance = x v.type = 'counter' #v.dispatch(values = [result[x]]) ___ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd