本文整理匯總了Python中objgraph.show_growth方法的典型用法代碼示例。如果您正苦於以下問題:Python objgraph.show_growth方法的具體用法?Python objgraph.show_growth怎麽用?Python objgraph.show_growth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類objgraph
的用法示例。
在下文中一共展示了objgraph.show_growth方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: trace_memory_start
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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"]
示例2: fix_missing_history
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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)
示例3: print_memory_growth_statistics
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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
示例4: show_growth
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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"
示例5: meminfo
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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())
示例6: cmd_objgraph
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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')
示例7: dump_objgraph
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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 "****"
示例8: trace_memory_stop
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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
)
示例9: show_growth
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
def show_growth():
if objgraph is None:
return "objgraph not installed"
objgraph.show_growth(limit=10)
return "Printed to console"
示例10: start_debug_shell
# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_growth [as 別名]
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')