Q
Q
qRoC2013-04-02 18:53:09
C++ / C#
qRoC, 2013-04-02 18:53:09

Help finding a memory leak

Memory leaks in functions:

static int xxxx_read_packet(AVFormatContext *s, AVPacket *pkt)
{
    struct xxxx *xxxx = s->priv_data;
    
    CFDataRef bitmapDataRef = CGDataProviderCopyData( CGImageGetDataProvider( xxxx->image ) );
    uint8_t *imgData = (uint8_t *)CFDataGetBytePtr( bitmapDataRef );

    av_init_packet( pkt );

    pkt->data = imgData;
    pkt->size = xxxx->frame_size;
    pkt->pts = curtime;

    CGImageRelease( xxxx->image );
    //CFRelease( bitmapDataRef );

    xxxx->image = CGWindowListCreateImage( CGRectInfinite, kCGWindowListOptionAll, kCGNullWindowID, kCGWindowImageDefault );

    return xxxx->frame_size;
}


I can't figure out where, please help.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Q
qRoC, 2013-04-03
@qRoC

Thank you all, the problem is crooked, but solved.

S
SadGnome, 2013-04-02
@SadGnome

Here is a similar question: stackoverflow.com/questions/11992791/ios-potential-leak-of-data-cfdatagetbyteptr
There seems to be a similar situation. Copy the data, and then call CFRelease, which is now commented out for some reason.

A
Andrew, 2013-04-02
@xaoc80

av_free_packet(pkt) must be called if xxxx_read_packet is not called after calling xxxx_read_packet.

E
elanc, 2013-05-19
@elanc

memwatch . Small and comfortable. I use them all the time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question