[Live-devel] MediaSink / Memory leak

Brad O'Hearne brado at bighillsoftware.com
Tue Mar 6 14:31:47 PST 2012


Ross, 

>>     delete[] sPropRecords;
>> 
>> with the error that the "pointer being freed was not allocated".
> 
> I don't understand why you're getting an error here; the code looks OK.

Yeah, I know the feeling!  ;-) But it would seem more than an issue of style, it outright crashes the entire app...

> FYI, in C++ "delete[]"ing (or "delete"ing) a NULL pointer is not an error (it has no effect).

Yeah...I've been wondering if I'm dealing with some compiler nuance in part. I did that to see if it would have any marked effect on the outcome. 

The only way I can get a run that doesn't crash is to remove the 

>>     delete[] sPropRecords;


line entirely, and as a result, the memory....

Brad

On Mar 6, 2012, at 3:16 PM, Ross Finlayson wrote:

>> This particular code snippet was taken directly from the Live555 H264VideoFileSink class implementation of its afterGettingFrame() method, so the exact code and usage context should be identical. 
>> 
>> Anyway, I have taken my app run it on Xcode, and this line pretty quickly crashes the app: 
>> 
>>     delete[] sPropRecords;
>> 
>> with the error that the "pointer being freed was not allocated".
> 
> I don't understand why you're getting an error here; the code looks OK.
> 
> 
>> I then figured that there was something internal to the parseSPropParameterSets which might conditionally allocate sPropRecords. So I wrapped the delete in a conditional: 
>> 
>>     if (sPropRecords)
>>     {
>>         delete[] sPropRecords;
>>     }
>> 
>> The error was the same
> 
> FYI, in C++ "delete[]"ing (or "delete"ing) a NULL pointer is not an error (it has no effect).
> 
> Ross Finlayson
> Live Networks, Inc.
> http://www.live555.com/
> 
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live555.com
> http://lists.live555.com/mailman/listinfo/live-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120306/6f571c64/attachment-0001.html>


More information about the live-devel mailing list