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 8472295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:01:31+00:00 2026-06-10T17:01:31+00:00

I am new to Python, writing something with pygame and it is very bitmap

  • 0

I am new to Python, writing something with pygame and it is very bitmap intensive. Here are certain (current) facts about it:

  1. All graphics files have the potential to be reused at any point in a program instance.
  2. It can take up 1GB+ memory if I pre-load everything in the beginning, even when there are no duplicates.
  3. It is not hard to load the images when they are (almost) needed i.e. the file sizes are very small compared to the memory usage, and it is easy to predict what will come next.

There are many suggestions not to use del, and I do not know if that applies to my case. I have thought about utilizing the garbage collection mechanism, by implementing a resource manager that holds the only reference to any loaded image, and it juggles through different images, roughly by removing the reference for one while re-loading an other.

However, I am not very sure if this really frees any memory at any point, and I don’t know how make the GC to actually keep the memory down consistently, as it seems that gc calls is quite expensive (and by default too infrequent)

So in summary, I would like to know whether the method outlined above is worth a try, and if not I hope someone could teach me other ways such as properly using del, and whether that fits pygame. Any help will be appreciated.

  • 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-10T17:01:34+00:00Added an answer on June 10, 2026 at 5:01 pm

    Try this, see if its good enough. http://www.pygame.org/wiki/LazyImageLoading?parent=CookBook

    When you first reference an item in an ImageController instance, it is
    loaded and returned. While a reference is kept to the image, it
    remains available in the ImageController. When the image no longer has
    any active references, it is removed from memory, and will be reloaded
    next time it is referenced.

    Keep your initial texture manager design as simple as possible. Afterwards, if profiling says you need more performance, then optimize.

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

Sidebar

Related Questions

I am new to python and I was writing something like: t = 0.
I am a bit new to Python, but an experienced programmer. I am writing
I'm really new to C -> Python interaction and am currently writing a small
Very new to python and can't understand why this isn't working. I have a
I'm writing Python scripts for Blender for a project, but I'm pretty new to
I am very very new to Python and I could use your help. I
I'm new to python, and it really confused me. I want to write something
I am new to python and am writing some scripts to automate downloading files
I am new to Python. I am writing an application using wxPython and I
I am fairly new to python, and have no experience with writing services for

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.