Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi,
I used "Analyse" on an ARC project, and see three warnings which are the
"Memory is never released, potential leak of memory pointed to by byteData".

What gives?

it's talking about this:
Code:
    // Check if the file already exists
    if ([filemgr fileExistsAtPath: dataFile])
    {
        // Read file contents and display in textBox
        NSData *databufferx;
        databufferx = [filemgr contentsAtPath: dataFile];
        
        NSUInteger len = [databufferx length];
        Byte *byteData = (Byte*)malloc(len);
        memcpy(byteData, [databufferx bytes], len);        
        
        // copy file into second half of array
        for (int ix = 0; ix < len; ix++) { 
            memoryfile[ix+1337481] = byteData[ix];
        }        
     
        
    }

Given it's an ARC project, I thought I can't release it if I wanted to.
At this point in the program, I am finished with everything except for memoryfile.
 
Last edited:
ARC only handles Obj-C objects. It does not handle C data. You'll need to manually release any C / CoreFoundation data.
 
ARC only handles Obj-C objects. It does not handle C data. You'll need to manually release any C / CoreFoundation data.

Ah.. thanks, that explains it.

How obvious is it?
Code:
free(byteData);
I hope this is not what happens as you learn Obj-C :D
 
Last edited:
On a related topic... Does ARC handle destroying C++ objects? I've noticed that when you make a new C++ project the ARC checkbox is still available... I'm wondering if that's a bug and it's not actually an option or a feature and it does work with C++.
 
On a related topic... Does ARC handle destroying C++ objects? I've noticed that when you make a new C++ project the ARC checkbox is still available... I'm wondering if that's a bug and it's not actually an option or a feature and it does work with C++.

Couldn't tell you sorry, It was always plain C for me,
but I imagine you can still use Apple UI stuff, and the option should be there for that.

Shouldn't be hard to create something, Analyse the project,
and see if Xcode complains. That's how I found out.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.