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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:28:22+00:00 2026-05-16T03:28:22+00:00

In my code, I use a singleton object as a central point in my

  • 0

In my code, I use a singleton object as a central point in my app to load and cache images the app frequently needs, so I don’t have to do resource-intensive memory allocation each time I load an image.

But there are times during the execution of my app where memory usage gets intense and I would like to release the cached image data. Currently, I’m just releasing the UIImage instances from my singleton when I get a memory warning.

I would prefer, however, to be able to release the entire singleton object. Is that possible? If so, how?

  • 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-16T03:28:23+00:00Added an answer on May 16, 2026 at 3:28 am

    Of course it is. Although it’s rather likely that the memory usage of this object is negligible compared to the images.

    By the nature of a singleton, you need to have an accessor for it, where you will create it if it does not currently exist:

    + (MySingletonClass*) mySingleton
    {
        if ( mySingleton == nil )
        {
            mySingleton = [[MySingletonClass alloc] init];
        }
    
        return mySingleton;
    }
    

    You just need to add another that you call when you want to destroy it:

    + (void) destroyMySingleton
    {
        [mySingleton release];
        mySingleton = nil;
    }
    

    If you keep references to it around elsewhere you’ll have trouble; don’t do that. If you access from multiple threads you’ll need to synchronize. Otherwise, it’s pretty straightforward — the getter will recreate when you next need it.

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

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The size of arrays in Java cannot be changed. So,… May 16, 2026 at 4:30 pm
  • Editorial Team
    Editorial Team added an answer MMC does not dictate how you talk to your code.… May 16, 2026 at 4:30 pm
  • Editorial Team
    Editorial Team added an answer In this case, in stead of your self made Compare… May 16, 2026 at 4:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Is there a way to implement a singleton object in C++ that is: Lazily
I have some confusion about when to use the self keyword during ivars assignment,
I need to get the spring application context from a non bean object. In
I need some advise on my PHP code organisation. I need classes where I
I'm using Visual Studio 2010 to write a simple C#/.NET GUI app, wherein I
I am testing a parser I have written in Scala using ScalaTest. The parser
I have perl 5.10.1 installed on my ubuntu machine. I wanted to install the
I'm still in need of help. I have website settings that I want to
What is the best practice on setting and keeping these global objects ? I
A few days ago, I had an issue with ASP.Net threading. I wanted to

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.