Python objgraph.show_growth() Examples
The following are 11
code examples of objgraph.show_growth().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
objgraph
, or try the search function
.
Example #1
Source File: misc.py From DueUtil with GNU General Public License v3.0 | 6 votes |
def meminfo(ctx, **_): mem_info = StringIO() objgraph.show_most_common_types(file=mem_info) await util.say(ctx.channel, "```%s```" % mem_info.getvalue()) mem_info = StringIO() objgraph.show_growth(file=mem_info) await util.say(ctx.channel, "```%s```" % mem_info.getvalue())
Example #2
Source File: Consolidate.py From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def fix_missing_history(self): with db.session_context() as sess: self.qlog.info("Querying for DB items without any history") end = sess.execute(""" SELECT t1.url FROM web_pages t1 LEFT JOIN web_pages_version t2 ON t2.url = t1.url WHERE t2.url IS NULL """) end = [tmp[0] for tmp in end] self.log.info("Found %s rows missing history content!", len(end)) loop = 0 remaining = len(end) for urlset in batch(end, 50): self.tickle_rows(sess, urlset) sess.expire_all() remaining = remaining - len(urlset) self.log.info("Processed %s of %s (%s%%)", len(end)-remaining, len(end), 100-((remaining/len(end)) * 100) ) print("Growth:") growth = objgraph.show_growth(limit=10) print(growth)
Example #3
Source File: utils.py From purerpc with Apache License 2.0 | 5 votes |
def print_memory_growth_statistics(interval_sec=10.0, set_pdb_trace_every=math.inf): num_iters = 0 import objgraph while True: num_iters += 1 await anyio.sleep(interval_sec) objgraph.show_growth() if num_iters == set_pdb_trace_every: pdb.set_trace() num_iters = 0
Example #4
Source File: profiling.py From CloudBot with GNU General Public License v3.0 | 5 votes |
def show_growth(): """- Print object growth data to the console""" if objgraph is None: return "objgraph not installed" objgraph.show_growth(limit=10) return "Printed to console"
Example #5
Source File: bot.py From rhinobot_heroku with MIT License | 5 votes |
def cmd_objgraph(self, channel, func='most_common_types()'): import objgraph await self.send_typing(channel) if func == 'growth': f = StringIO() objgraph.show_growth(limit=10, file=f) f.seek(0) data = f.read() f.close() elif func == 'leaks': f = StringIO() objgraph.show_most_common_types(objects=objgraph.get_leaking_objects(), file=f) f.seek(0) data = f.read() f.close() elif func == 'leakstats': data = objgraph.typestats(objects=objgraph.get_leaking_objects()) else: data = eval('objgraph.' + func) return Response(data, codeblock='py')
Example #6
Source File: main.py From powerpool with BSD 2-Clause "Simplified" License | 5 votes |
def dump_objgraph(self): """ This is a debugging method designed to be called from the datagram port. It helps us debug a memory 'leak' """ import gc gc.collect() import objgraph print "Dumping object growth ****" objgraph.show_growth(limit=100) print "****"
Example #7
Source File: job.py From mrq with MIT License | 5 votes |
def trace_memory_start(self): """ Starts measuring memory consumption """ self.trace_memory_clean_caches() objgraph.show_growth(limit=30) gc.collect() self._memory_start = self.worker.get_memory()["total"]
Example #8
Source File: job.py From mrq with MIT License | 5 votes |
def trace_memory_stop(self): """ Stops measuring memory consumption """ self.trace_memory_clean_caches() objgraph.show_growth(limit=30) trace_type = context.get_current_config()["trace_memory_type"] if trace_type: filename = '%s/%s-%s.png' % ( context.get_current_config()["trace_memory_output_dir"], trace_type, self.id) chain = objgraph.find_backref_chain( random.choice( objgraph.by_type(trace_type) ), objgraph.is_proper_module ) objgraph.show_chain(chain, filename=filename) del filename del chain gc.collect() self._memory_stop = self.worker.get_memory()["total"] diff = self._memory_stop - self._memory_start context.log.debug("Memory diff for job %s : %s" % (self.id, diff)) # We need to update it later than the results, we need them off memory # already. self.collection.update( {"_id": self.id}, {"$set": { "memory_diff": diff }}, w=1 )
Example #9
Source File: profiling.py From CloudBot with GNU General Public License v3.0 | 5 votes |
def show_growth(): if objgraph is None: return "objgraph not installed" objgraph.show_growth(limit=10) return "Printed to console"
Example #10
Source File: bot.py From MusicBot with MIT License | 5 votes |
def cmd_objgraph(self, channel, func='most_common_types()'): import objgraph await self.send_typing(channel) if func == 'growth': f = StringIO() objgraph.show_growth(limit=10, file=f) f.seek(0) data = f.read() f.close() elif func == 'leaks': f = StringIO() objgraph.show_most_common_types(objects=objgraph.get_leaking_objects(), file=f) f.seek(0) data = f.read() f.close() elif func == 'leakstats': data = objgraph.typestats(objects=objgraph.get_leaking_objects()) else: data = eval('objgraph.' + func) return Response(data, codeblock='py')
Example #11
Source File: util.py From tapas with GNU General Public License v2.0 | 5 votes |
def start_debug_shell(d=None, port=9000): # Add a manhole shell import twisted.manhole.telnet f = twisted.manhole.telnet.ShellFactory() f.namespace['_'] = d try: import objgraph f.namespace['g'] = objgraph.show_growth except Exception: pass return reactor.listenTCP(port, f, interface='127.0.0.1')