I wrote a program which is like a daemon, running all time in a while(1) loop, and i have to init a NSString as something like "initwithFormat" in the loop, the following is an example of my code, i cannot create a static string or create outside the loop because i have to mod the string in every loop run in my real case. Now i can't release the str by [string release], and it occupy all my memory in the whole system. what's wrong i did? please help!
long i = 0;
while(1){
NSString* outstr = [[NSString alloc]initWithFormat"start!"];
outstr = [outstr stringByAppendingFormat"%d",i];
[outstr release];
}
it finally ate up all my memory.
but it just can't release the memory, i tried autorelease, NSAutoreleasePool, and garbage collector in xcode 3.0, all just doesn't work!
long i = 0;
while(1){
NSString* outstr = [[NSString alloc]initWithFormat"start!"];
outstr = [outstr stringByAppendingFormat"%d",i];
[outstr release];
}
it finally ate up all my memory.
but it just can't release the memory, i tried autorelease, NSAutoreleasePool, and garbage collector in xcode 3.0, all just doesn't work!