Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Memory Leak with Active Timer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Leak with Active Timer



On 2 Nov 2007, at 23:40, Rolf Howarth wrote:

I don't think Apple have introduced any new bugs or memory leaks the last few years.

I _think_ that this is new on 7.2 on Mac, as our app now leaks big- time - difficult to install old versions of QT to find out though.


The leak manifests itself as ~1MB leak of process memory per play-new- clip in our app on 7.2. I'm having difficulty persuading QA that we can release it in this state.

Duncan

public class QuicktimeLeakingTimersTest extends TestCase {

private static File FILE = new File("./testdata/ testclip.mov").getAbsoluteFile();

static {
if (!QTSession.isInitialized()) {
try {
QTSession.open();
} catch (QTException e) {
throw new RuntimeException("Could not initialize Quicktime", e); //$NON-NLS-1$
}
}
}


    private DataRef dataRef;
    private Movie movie;
    private Timer timer;

    @Override
    protected void setUp() throws Exception {
        dataRef = new DataRef(new QTFile(FILE));
    }

/**
* If we just create a movie and a timer on it, then both can be disposed by gc
*
* Profiling shows that there are no instances of Movie or Timer left
*/
public void testShowQuicktimeDoesReleaseNonActivatedTimers() throws QTException {
movie = Movie.fromDataRef(dataRef, 0);
timer = new Timer(1, 1, null, movie);
checkCanDisposeMovieAndTimer();
}


/**
* If we just create a movie and a timer on it, then activate the timer,
* neither can be disposed by gc, even when the timer is stopped.
*
* Profiling shows that the movie is held by the timer, which is held by
* QTCallbackManagement, which is JNI global.
*/
public void testShowQuicktimeDoesNotReleaseActivatedTimers() throws QTException {
movie = Movie.fromDataRef(dataRef, 0);
timer = new Timer(1, 1, null, movie);
timer.setActive(true);


        timer.setRate(0);
        timer.setTickling(false);
        timer.setActive(false);
        try {
            checkCanDisposeMovieAndTimer();
            fail("didn't fail");
        } catch (AssertionFailedError expected) {}
    }

private void checkCanDisposeMovieAndTimer() {
WeakReference<Movie> movieRef = new WeakReference<Movie> (movie);
WeakReference<Timer> timerRef = new WeakReference<Timer> (timer);
movie = null;
timer = null;


        for (int i = 0; i < 100; i++) {
            System.gc();
            System.runFinalization();
            if (movieRef.get() != null && timerRef.get() != null)
                break;
        }

        assertNull(timerRef.get());
        assertNull(movieRef.get());
    }

}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-java mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Three New QT Documents Available (From: "email@hidden" <email@hidden>)
 >Re: Three New QT Documents Available (From: Rolf Howarth <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.