Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:40:10+00:00 2026-06-04T21:40:10+00:00

I’ve been trying to use tornado-redis (which is basically a fork of brükva slightly

  • 0

I’ve been trying to use tornado-redis (which is basically a fork of brükva slightly modified to work with tornado.gen interface instead of adisp) in order to deliver events by using redis’ pubsub.

So I wrote down a little script to test things out inspired by 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()

Unfortunately, as I PUBLISHed through redis-climemory usage kept on rising.

In order to profile memory usage I first tried to use guppy-pe but it wouldn’t work under python 2.7 (Yes even tried trunk) so I fell back to 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()

Now each time I PUBLISHed I could see that some objects were never released:

                                            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

Now that I know there’s really a memory leak, how do I track where those objects are created? I guess I should start here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:40:11+00:00Added an answer on June 4, 2026 at 9:40 pm

    Upgrading Tornado to version 2.3 should fix this issue.

    I was having the same issue where ExceptionStackContext were leaking very quickly. It was related to this bug report: https://github.com/facebook/tornado/issues/507 and fixed in this commit: https://github.com/facebook/tornado/commit/57a3f83fc6b6fa4d9c207dc078a337260863ff99. Upgrading to 2.3 took care of the issue for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.