Sammio2
Sammio2

Reputation: 7462

How to deallocate memory on the iPhone?

This is probably a very silly and simple question to most of you, but I have the following code creating a temporary array within a function, at the end of the function i need to release the memory. Here is the code:

double *FFTOut;

//FFT Out removes the alternative zeros added in the earler phase (before the FFT)
FFTOut = (double *)malloc((CFArray1Size)* sizeof(double));

So the pointer FFTOut is to a block of memory, I have tried the following...

[FFTOut release];

and...

[FFTOut dealloc];

Neither of which work. I'm sorry to post such a trivial question, but i can't seem to find the answer to this? Unless I am allocating the memory incorrectly in the first place, but I don't think this is the case?

Many Thanks

Upvotes: 0

Views: 641

Answers (1)

terry franguiadakis
terry franguiadakis

Reputation: 140

If you malloc, you have to use free().

release is for objective-c object that you've either new'd or alloc'd.

Upvotes: 4

Related Questions