On Sep 3, 2008, at 10:02 AM, [EMAIL PROTECTED] wrote:

I'm trying to calculate the elapsed time by calling this twice and getting the difference.

double Seconds()
{
  return [[NSDate date] timeIntervalSince1970];
}


How about replacing that with:

        return [NSDate timeIntervalSinceReferenceDate];

That said, I would bet that there are simple C APIs that would be more efficient to use for this purpose.


This is being called from an audio play back proc which is being called about 100 times a second. I'm getting this error message in the log window a whole bunch of times.

2008-09-03 09:39:30.766 App[321] *** _NSAutoreleaseNoPool(): Object 0x36acd0 of class NSCFDate autoreleased with no pool in place - just leaking


The reason is that you're executing the code above on a non-main thread. See the documentation for NSAutoReleasePool for details (or just use Google), but in general:

"Cocoa expects there to be an autorelease pool always available. If a pool is not available, autoreleased objects do not get released and you leak memory. NSAutoreleasePool objects are automatically created and destroyed in the main thread of applications based on the Application Kit, so your code normally does not have to deal with them."

On threads that you set up, you have to manage the top level autorelease pool manually.


j o a r


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to