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

  • Home
  • SEARCH
  • 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 7522757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:36:27+00:00 2026-05-30T02:36:27+00:00

I have a custom gtk.treeview wrapper class that manages its own liststore. The class

  • 0

I have a custom gtk.treeview wrapper class that manages its own liststore. The class has its own method that clears the liststore’s data and overwrites it with new data. For the purpose of testing memory consumption,the treeview just displays 50,000 rows of integers in 8 columns.

I’ve noticed that every call to my function that updates the liststore with data seems to increase the memory the application uses, and it never goes back down after data is cleared.

Here is my simple treeview implementation:

class TreeViewPrototype(gtk.TreeView):
    def __init__(self):
        gtk.TreeView.__init__(self)

        self.columns = [str, str, str, str, str, str, str, str]
        # Initialize Treeview  and TreeViewColumns here
        # Setup columns
        self.liststore = gtk.ListStore(*self.columns)
        self.set_model(self.liststore)

    def set_list_model(self):
        self.liststore.clear()
        self.liststore = gtk.ListStore(*self.columns)
        # Populate liststore with dummy data
        for i in range(50000):
            row = []
            for j in range(len(self.columns)):
                row.append("%d[%d]"%(i,j))
            self.liststore.append(row)

It seems to me that every call to set_list_model, when I overwrite the liststore with a new one, it never unallocates the memory of the data. What am I doing wrong?

  • 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-05-30T02:36:28+00:00Added an answer on May 30, 2026 at 2:36 am

    The problem seems to be with the reference to the liststore in the
    treeview. Because the treeview is a container that is present
    throughout the entire lifecycle of the application, the old liststore
    hangs around, being still referenced by the treeview’s constructor. If
    a new liststore is created everytime and no reference is held by the
    treeview, that problem seems to go away.

    My Solution:

    class TreeViewPrototype( gtk.TreeView ):
       def __init__(self):
           gtk.TreeView.__init__(self)
           self.columns = [str,str,str,str,str,str,str,str]
           #TreeView Initialization
    
       def set_list_model( self ):
           self.set_model(None)
           liststore = gtk.ListStore( *self.columns)
           for i in range( 50000 ):
               row = []
               for j in range( len( self.columns)):
                   row.append( "%d[%d]"%(i,j))
               liststore.append( row )
           self.set_model( liststore )
    

    Using set_model(None) seems to correctly dereference the current
    liststore in the model so it doesn’t hang around in memory.

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

Sidebar

Related Questions

I have custom exceptions in my django project that look like this: class CustomFooError(Exception):
I have custom class that extends WebViewPage that I use as the base for
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have a few models that need to have custom find conditions placed on
I have custom drupal module. I receive result from a webservice that I need
I have custom SiteMapProvider and RoleProvider that works together properly: IsAccessibleToUser returns false if
I have custom code inside of a SSRS report that needs to get the
I have custom assembly that is loaded on runtime. at this point i have
I have custom slider that I use the following touch event to respond to:
I have custom JSP tags that generate some HTML content, along with some javascript

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.