• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Memory Leak with NSMutable String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Leak with NSMutable String


  • Subject: Memory Leak with NSMutable String
  • From: "Alexander F. Hartner" <email@hidden>
  • Date: Mon, 26 Jan 2004 13:14:28 +0200

The following code uses as diagnosed with ObjectAlloc and MallocDebug
more and more memory. It seems that NSMutableString don't get properly
released. I am still quite new to Objective C and most likely am doing
something incredible stupid. Any suggestions are welcome.

Thanks
Alex


#import <Foundation/Foundation.h>
#include <stdio.h>

void doOtherStuff()
{
NSMutableString *data = [NSMutableString stringWithCapacity:1000];
[data appendString:@"DATA"];
[data release];
printf("Interation \n");
}

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// insert code here...
NSLog(@"Hello, World!");
int counter=0;
for (counter=0; counter<1000000;counter++)
{
doOtherStuff();
}

[pool release];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Memory Leak with NSMutable String
      • From: Peter Maurer <email@hidden>
    • Re: Memory Leak with NSMutable String
      • From: Fabrizio La Rosa <email@hidden>
  • Prev by Date: NSToolTipAttributeName and NSCursorAttributeName
  • Next by Date: Re: Any new/updated Cocoa books soon?
  • Previous by thread: NSToolTipAttributeName and NSCursorAttributeName
  • Next by thread: Re: Memory Leak with NSMutable String
  • Index(es):
    • Date
    • Thread