0

I am using iOS 7 and I am getting memory warnings in this part of code, but I'am not able to understand how the retain count increases as I release imageToSave variable too.

This is image of code when i analyze my code

tanz
  • 2,557
  • 20
  • 31
kshitij godara
  • 1,523
  • 18
  • 30
  • 2
    This is not quite an answer, but why are you not using ARC? – Stefan Fisk Jan 28 '14 at 11:39
  • Are `finalOutput:` return autoreleased object? By naming convention it should be autoreleased. If not, then method should be named `createFinalOutput:` – Cy-4AH Jan 28 '14 at 11:43
  • because i started it writing in ios 6 as there was option of choosing or not choosing arc ,i didn't choose that time ,as you all know ,that time we all need more time to understand arc :-) – kshitij godara Jan 28 '14 at 11:44
  • @Cy-4AH sorry to ask but what difference will going to be by changing name of method ? – kshitij godara Jan 28 '14 at 11:48
  • 1
    I second @StefanFisk. I wonder why people still go the hard way of manual memory management. – Isuru Jan 28 '14 at 11:49
  • 2
    @Isuru Because it gives you more control over ARC and way better memory management then ARC – Retro Jan 28 '14 at 11:52
  • 1
    I've never seen an example of when non-ARC code performs better than ARC code. Apple has also stated several times that ARC code will have its retain/release calls optimized by the compiler, so that unnecessary calls are removed completely. – Stefan Fisk Jan 28 '14 at 11:57
  • @StefanFisk read here http://stackoverflow.com/questions/8760431/to-arc-or-not-to-arc-what-are-the-pros-and-cons – Retro Jan 28 '14 at 12:00
  • read it, but I can't find any mention of better memory management, only the possibility of doing odd stuff like ids in structs without cumbersome casts. – Stefan Fisk Jan 28 '14 at 12:15
  • 1
    @kshitijgodara, it's just naming convention that object returned by methods, started with `copy`, `create`, `new`, `int`, should be released. In other cases object is already autoreleased. By this convention and looking at yours code, you don't need release imageToSave. – Cy-4AH Jan 28 '14 at 15:50
  • @StefanFisk,@Isuru,@Retro - Guys nyc conversation ,when such great mind discuss things out,every feel obliged by getting shower of knowledge . – kshitij godara Jan 29 '14 at 07:14

2 Answers2

1

Static analyser not always write about memory leak but its assuming that when you are calling finalOutput its returning you an allocated object mean +1 retain count object which is never used and its treating this waring as memory leak!

Retro
  • 3,985
  • 2
  • 17
  • 41
1

You have not allocated memory to this object yourself, so you don't own it. And you are still releasing it.You can't release objects you don't own. Unless you use alloc method to allocate memory, you can't just release them........

Rana
  • 451
  • 4
  • 16