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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:12:51+00:00 2026-05-18T01:12:51+00:00

I have a couple labels I am using as a HUD for the player

  • 0

I have a couple labels I am using as a HUD for the player during a game. I am updating these labels frequently, so that the player has up-to-date information. The problem is is that I’ve been using

uiLabel.text = [NSString stringWithFormat:@"%3.0f", value];

to pass the new value that the label should have. I have noticed, however, that I have something of a soft-memory leak here. As I’m doing this update multiple times a second and this creates a string that is set to autorelease, I’m ending up taking more memory than I need. And keeping it, as the view is not going away.

I also tried to alloc and release strings explicitly, such as:

NSString* value = [[NSString alloc] initWithFormat: @"%3.0f", value];
uiLabel.text = value;
[value release];

However, I find that this seems to cause the same thing, but faster, though I don’t know why. In this situation I would have thought there should never be strings sitting around waiting to be released at all, since I’m so explicitly dismissing them.

Can anyone see what I’m doing here that I obviously am failing to see? Is there a better/more preferred way to handle this? Some cursory searching didn’t turn up much for me.

  • 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-18T01:12:52+00:00Added an answer on May 18, 2026 at 1:12 am

    You’re not doing anything out of the ordinary. Even with:

    uiLabel.text = [NSString stringWithFormat:@"%3.0f", value];
    

    the autorelease pool gets drained every time your code returns control to the run loop (so at least as often as you see the UI updating). If you see growing memory allocations, you should look elsewhere.

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

Sidebar

Related Questions

I have a couple old services that I want to completely uninstall. How can
I have a couple of triggers on a table that I want to keep
I am using SLD to style output from my geoserver. I have couple types
I have a couple things going on right now. I have a form that
I have created a couple of simple functions in VB.NET that simply return a
I have couple labels and tabs in my site and I need to make
I have a couple of functions that perform HTTP POST/GET/HEAD requests. For the POST
We have a couple of ASP.NET WebForms applications that use the ADAM Membership provider,
We have a couple of winforms applications that host a bunch of icons in
I have a converter which has a couple of input variables (an object and

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.