Re: Preventing beach balls
Re: Preventing beach balls
- Subject: Re: Preventing beach balls
- From: Paul Borokhov <email@hidden>
- Date: Sat, 3 Mar 2007 00:06:31 -0800
So...now that threads have been implemented...
It appears that NSLock is leaking memory. My application performs regular updates and retrieves data every 6 seconds from the web. Each update is done by a separate method and each method is detached from the main thread when the timer fires. Now, NSLock uses continuously more memory as the application runs, according to ObjectAlloc. This is also happening to a lesser extent with CFBag, CFRunLoopSource, and NSRecursiveLock. I'm not using any of these in my code directly so I'm a bit curious as to why they are using memory, and more and more of it with each minute.
Any ideas?
Paul
----------Original Message----------
On 2/18/07 19:14 , Jim Thomason (email@hidden) wrote:
> Threads. You want threads. But you don't need ports or proxies or
> anything. I wonder if you were reading about distributed objects,
> which would start wanting those things. Distributed objects is easy,
> too, and can be used for communication between threads as well as
> between processes (and machines!), but it's overkill if you don't
> actually need it. It is really cool and easy technology, though.
>
> An easy approach is to start up a new thread when you want to do the action.
>
> Instead of [self foo], you'd have something like:
>
> [NSThread detachNewThreadSelector:@selector(runFooInThread:)
> toTarget:self withObject:nil];
>
> then:
>
> -(void) runFooInThread:(id) object {
> NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>
> [self foo];
>
> [pool release];
>
> }
>
> It may be keen to somehow add code to the foo method (if you can) to
> allow it to be canceled by the user. Otherwise you'll prevent the
> beachball, but the user won't be able to stop it regardless.
>
> Note - some things (mainly involving UI, but there are others) must be
> done on the main thread.
> performSelectorOnMainThread:withObject:waitUntilDone: is your friend
> here.
>
> It's really quite easy.
>
> -Jim.....
>
> On 2/18/07, Paul Borokhov <email@hidden> wrote:
>> Hi all,
>> I'm trying to find a relatively _easy_ solution to prevent
>> beachballing in my application. I did take a look at threading, but
>> all of the provided examples seem to imply inter-object
>> communication with ports and proxies, whereas I don't need anything
>> near as complicated in my application. I just want to be able to
>> execute [self foo] and yet leave the interface responsive at all
>> times. All I need is something like (oneway void), but that has no
>> effect on calls made by the object to itself...so, any other
>> solutions?
>> Thanks!
>> Paul
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden