나는 redis' pubsub을 사용하여 이벤트를 전달하기 위해 기본적으로 brükva의 포크가 adisp 대신 tornado.gen 인터페이스와 함께 작동하도록 약간 수정 된 tornado-redis을 사용하려고했습니다.pympler를 사용하여 토네이도 - redis에서 메모리 누수를 추적/수정하는 방법은 무엇입니까?
그래서 나는 작은 스크립트를 써서 this example에서 영감을 얻은 것들을 테스트 해 보았습니다. 불행하게도
import os
from tornado import ioloop, gen
import tornadoredis
print os.getpid()
def on_message(msg):
print msg
@gen.engine
def listen():
c = tornadoredis.Client()
c.connect()
yield gen.Task(c.subscribe, 'channel')
c.listen(on_message)
listen()
ioloop.IOLoop.instance().start()
, 나는 PUBLISH
에드 redis-cli
메모리 사용을 통해 상승에 보관한다.
메모리 사용량을 프로파일 링하기 위해 먼저 guppy-pe을 사용하려고했지만 파이썬 2.7 (예 : 트렁크 시도)에서 작동하지 않으므로 pympler으로 떨어졌습니다.
import os
from pympler import tracker
from tornado import ioloop, gen
import tornadoredis
print os.getpid()
class MessageHandler(object):
def __init__(self):
self.memory_tracker = tracker.SummaryTracker()
def on_message(self, msg):
self.memory_tracker.print_diff()
@gen.engine
def listen():
c = tornadoredis.Client()
c.connect()
yield gen.Task(c.subscribe, 'channel')
c.listen(MessageHandler().on_message)
listen()
ioloop.IOLoop.instance().start()
이제 때마다 나는
PUBLISH
에드 나는 일부 개체가 해제되지 않을 수있었습니다 : 해당 개체가 생성되는 경우 어떻게 추적합니까,
types | # objects | total size
===================================================== | =========== | ============
dict | 32 | 14.75 KB
tuple | 41 | 3.66 KB
set | 8 | 1.81 KB
instancemethod | 16 | 1.25 KB
cell | 22 | 1.20 KB
function (handle_exception) | 8 | 960 B
function (inner) | 7 | 840 B
generator | 8 | 640 B
<class 'tornado.gen.Task | 8 | 512 B
<class 'tornado.gen.Runner | 8 | 512 B
<class 'tornado.stack_context.ExceptionStackContext | 8 | 512 B
list | 3 | 504 B
str | 7 | 353 B
int | 7 | 168 B
builtin_function_or_method | 2 | 144 B
types | # objects | total size
===================================================== | =========== | ============
dict | 32 | 14.75 KB
tuple | 42 | 4.23 KB
set | 8 | 1.81 KB
cell | 24 | 1.31 KB
instancemethod | 16 | 1.25 KB
function (handle_exception) | 8 | 960 B
function (inner) | 8 | 960 B
generator | 8 | 640 B
<class 'tornado.gen.Task | 8 | 512 B
<class 'tornado.gen.Runner | 8 | 512 B
<class 'tornado.stack_context.ExceptionStackContext | 8 | 512 B
object | 8 | 128 B
str | 2 | 116 B
int | 1 | 24 B
types | # objects | total size
===================================================== | =========== | ============
dict | 32 | 14.75 KB
tuple | 42 | 4.73 KB
set | 8 | 1.81 KB
cell | 24 | 1.31 KB
instancemethod | 16 | 1.25 KB
function (handle_exception) | 8 | 960 B
function (inner) | 8 | 960 B
generator | 8 | 640 B
<class 'tornado.gen.Task | 8 | 512 B
<class 'tornado.gen.Runner | 8 | 512 B
<class 'tornado.stack_context.ExceptionStackContext | 8 | 512 B
list | 0 | 240 B
object | 8 | 128 B
int | -1 | -24 B
str | 0 | -34 B
을 지금은 정말 메모리 누수가 알고 있다고? 나는 here을 시작해야한다고 생각하니?
이 문제에 대해 알려 주셔서 감사합니다. 나는 격상시키고 누설 + 감속은 갔다 :) –