Re: NSTextView & Leaking Memory
Re: NSTextView & Leaking Memory
- Subject: Re: NSTextView & Leaking Memory
- From: publiclook <email@hidden>
- Date: Sat, 2 Aug 2003 14:39:25 -0400
In Appkit applications, the default autorelease pool is only
deallocated once per event cycle. If you are doing a lot of work
inside a loop and never letting events be processed, the default pool
is never dealocated and therefore does not release the objects it
contains.
The solution is simple and well documented by Apple and others
including this list:
Inside a loop:
{
// Create your own local pool
localPool = [[NSAutoreleasePool alloc] init];
// do something that autoreleases objects
// Cause local pool to be deallocated and it will release all
contained objects
[localPool release];
}
Forgive me if I have misunderstood your question. It wasn't clear if
you are talking about a long running loop.
On Saturday, August 2, 2003, at 12:12 PM, Chris Ross wrote:
Hi,
I am completely stumped about this problem. I have a NSTextView
that I am updating by creating an NSMutableAttributedString and using
the [[textView textStorage] setAttributedString:] method.
The attributed string consists of a number of lines of text each
made up from a number of other AttributedStrings each with different
attributes. [on average 6 strings per line].
When the strings have been built and added to the NSTextView. The
display updates.
Now, when I do this a chunk of memory is allocated, when I do it
again (separated with [textView setString:@""]) more memory is
allocated.
The strings never seem to get free'd even though everything sits in
a auto-release pool. 500 lines of the text tends to generate ~6000
objects.
Does anyone know of this problem ? is it me ? How can I force the
attributed strings to be free'd up when the display is cleared ?
This has been driving me up the wall as the program goes from about
5 megs memory usage [RPRVT] to 70 megs overnight.
Any help would be very much recieved,
Regards,
Chris
_______________________________________________
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.
_______________________________________________
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.