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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:13:31+00:00 2026-06-12T00:13:31+00:00

I started to monitor app memory usage using technique described in here: Programmatically retrieve

  • 0

I started to monitor app memory usage using technique described in here:
Programmatically retrieve memory usage on iPhone

I wrote 3 tests to try it out and this is what I found:

- (void)test1 {
for (int i = 0; i < 1000; i++) {
    NSMutableString *str = [NSMutableString stringWithString:@""];
    for (int j = 0; j < 1000; j++) {
        [str appendString:@"some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string "];
    }
}    

- (void)test2 {
for (int i = 0; i < 100000; i++) {
    @autoreleasepool {
        NSString *stri = @"";
        stri = [NSString stringWithFormat:@"%d some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really", i];
    }
}


- (void)test3 {
NSString *str = @"";
for (int i = 0; i < 500; i++) {
    str = [str stringByAppendingFormat:@"%d some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really long string some really", i];
}

When I call test1 or test3 memory gets allocated and deallocated properly – I can see it using the report_memory function described in the link above.
But when I call test2 memory does not get deallocated – report_memory goes up and up. If I call test2 several times my app receives memory warning and gets terminated.

I’m using ARC. Can anyone explain what’s going in 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-12T00:13:32+00:00Added an answer on June 12, 2026 at 12:13 am

    Nailed it!!! I enabled Zombie Objects and forgot about them thus any allocated objects were not getting deallocated even when I was using the @autoreleasepool block.

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

Sidebar

Related Questions

So I've just started to write tests for my in-progress javascript app, using sinon.js
If a Java program is started, it get's in the system process-monitor the name
Started using Visual Studio 2012 RC since yesterday, We have one WCF solution. Whenever
Started recently, basically every time I try to fetch or commit it gives me
Started making a game. Here's some of my code. package games.tribe.screens; import games.tribe.model.World; import
I've started coding on a 30 inch monitor and am wondering if it's possible
I want my application to monitor and Log the Process that are started and
I am working on a God script to monitor my Unicorns. I started with
I have a little application here which deals with QuickTime video using QTKit. This
I've started using boost::signals2 instead of my old signals-code. I'm having a problem with

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.