• 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
Re: Background Process?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Background Process?


  • Subject: Re: Background Process?
  • From: Shawn Erickson <email@hidden>
  • Date: Wed, 11 Mar 2009 09:59:33 -0700

#import <Foundation/Foundation.h>

@interface Foo : NSObject
- (void)run;
- (void)fire:(NSTimer*)time;
@end

@implementation Foo

- (void) run
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

    [NSTimer scheduledTimerWithTimeInterval:5.0 target:self
selector:@selector(fire:) userInfo:nil repeats:YES];

    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]];

    [pool release];
}

- (void)fire:(NSTimer*)timer
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

    NSLog(@"FIRED");

    [pool release];
}

@end

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

    Foo* foo = [[[Foo alloc] init] autorelease];
    [NSThread detachNewThreadSelector:@selector(run) toTarget:foo
withObject:nil];

    sleep(4 * 60);

    [pool release];

    return 0;
}

[0:525] > time ./TimerTest& sample TimerTest
[1] 66952
Sampling process 66954 for 10 seconds with 1 millisecond of run time
between samples
2009-03-11 09:56:55.454 TimerTest[66954:1003] FIRED
2009-03-11 09:57:00.454 TimerTest[66954:1003] FIRED
Sampling completed, processing symbols...
Sample analysis of process 66954 written to file
/tmp/TimerTest_66954.AXF9SU.sample.txt

....

Analysis of sampling TimerTest (pid 66954) every 1 millisecond
Call graph:
    8492 Thread_2907
      8492 start
        8492 main
          8492 sleep$UNIX2003
            8492 __semwait_signal
              8492 __semwait_signal
    8492 Thread_2a03
      8492 thread_start
        8492 _pthread_start
          8492 __NSThread__main__
            8492 -[NSThread main]
              8492 -[Foo run]
                8492 -[NSRunLoop(NSRunLoop) runUntilDate:]
                  8492 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
                    8492 CFRunLoopRunInMode
                      8492 CFRunLoopRunSpecific
                        8489 mach_msg
                          8489 mach_msg_trap
                            8489 mach_msg_trap
                        3 __NSFireTimer
                          3 -[Foo fire:]
                            3 NSLog
                              3 NSLogv
                                3 _CFLogvEx
                                  3 __CFLogCString
                                    1 CFCalendarCreateWithIdentifier
                                      1 CFTimeZoneCopyDefault
                                        1 CFTimeZoneCopySystem
                                          1 CFTimeZoneCreateWithName
                                            1 open$UNIX2003
                                              1 open$UNIX2003
                                    1 asl_close
                                      1 notify_cancel
                                        1 _notify_server_cancel
                                          1 mach_msg
                                            1 mach_msg_trap
                                              1 mach_msg_trap
                                    1 asl_free
                                      1 asl_free

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
        __semwait_signal        8492
        mach_msg_trap        8490
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Follow-Ups:
    • Re: Background Process?
      • From: Kyle Sluder <email@hidden>
References: 
 >Background Process? (From: Pierce Freeman <email@hidden>)
 >Re: Background Process? (From: Darren Minifie <email@hidden>)
 >Re: Background Process? (From: Michael Ash <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)
 >Re: Background Process? (From: Roland King <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)
 >Re: Background Process? (From: Chris Suter <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)
 >Re: Background Process? (From: Ken Thomases <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: EXC_BAD_ACCESS on NSImageView::setImage
  • Next by Date: Re: Garbage collected and non-garbage collected
  • Previous by thread: Re: Background Process?
  • Next by thread: Re: Background Process?
  • Index(es):
    • Date
    • Thread