Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395130
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:15:11+00:00 2026-05-18T04:15:11+00:00

I have an instance of AVPlayer in my application. I use the time boundary

  • 0

I have an instance of AVPlayer in my application. I use the time boundary observing feature:

[self setTimeObserver:[player addBoundaryTimeObserverForTimes:watchedTimes
    queue:NULL usingBlock:^{
        NSLog(@"A: %i", [timeObserver retainCount]);
        [player removeTimeObserver:timeObserver];
        NSLog(@"B: %i", [timeObserver retainCount]);
        [self setTimeObserver:nil];
    }]];

The problem is that according to Instruments I am leaking some arrays and values somewhere around this code. I checked the retain count of the time-observing token returned by AVPlayer on places marked A and B in the sample code. At the A point the retain count is 2, at point B the retain count increases to 3 (!). Adding a local autorelease pool does not change anything. I know that retain count is not a reliable metric, but this seems to be fishy. Any ideas about why the retain count increases or about my leaks? The stack trace at the leak point looks like this:

   0 libSystem.B.dylib calloc
   1 libobjc.A.dylib _internal_class_createInstanceFromZone
   2 libobjc.A.dylib class_createInstance
   3 CoreFoundation __CFAllocateObject2
   4 CoreFoundation +[__NSArrayI __new::]
   5 CoreFoundation -[__NSPlaceholderArray initWithObjects:count:]
   6 CoreFoundation +[NSArray arrayWithObjects:count:]
   7 CoreFoundation -[NSArray sortedArrayWithOptions:usingComparator:]
   8 CoreFoundation -[NSArray sortedArrayUsingComparator:]
   9 AVFoundation -[AVPlayerOccasionalCaller initWithPlayer:times:queue:block:]
  10 AVFoundation -[AVPlayer addBoundaryTimeObserverForTimes:queue:usingBlock:]

If I understand things correctly, AVPlayerOccasionalCaller is the “opaque” object returned by addBoundaryTimeObserverForTimes:queue:usingBlock:, or the time observer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:15:12+00:00Added an answer on May 18, 2026 at 4:15 am

    Do not use -retainCount.

    The absolute retain count of an object is meaningless.

    You should call release exactly same number of times that you caused the object to be retained. No less (unless you like leaks) and, certainly, no more (unless you like crashes).

    See the Memory Management Guidelines for full details.


    In this specific case, the retain count you are printing is entirely irrelevant. removeTimeObserver: is probably retaining and autoreleasing the object. Doesn’t really matter; it is an implementation detail.

    When using the Leaks template in Instrument, note that the Allocations instrument is configured to record reference counts. When you have detected a “leak”, look at the list of reference count events for that object. There will likely be a stack where some code of yours is triggering an extra retain. If not, it might be a framework bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an audio player that I'm building using AVPlayer. Currently, I keep the
I'd like to have instance methods of a class return self, and be init
I am confused between NSString and NSMutable string usage. Suppose I have instance variables
I have an instance variable called @filtered_ratings = params[:ratings].keys However, if params[:ratings] is nil
I have an instance of the Popen class created through subprocess.Popen. I would like
I have an instance method that I'd like to invoke directly using the callback
I have an instance of UIToolbar that contains a UITextField inside. I'd like to
I have an instance of ObservableCollection bound to a WPF listbox with two separate
I have an instance of Class A that I want to refer to in
I have a instance of Oracle Access Manager set up on Server A and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.