I have a class named Ephemerides that does large amount of calculations and then returns an array of the results. I call this class from one of my view controllers in viewWillAppear. Everything works fine, but when I use instruments to check for leaks this always shows up as a leak. I have tried everything I can think of to release the object but so far I have had no luck.
Here is the relevant viewWillAppear code that calls the class:
Code:
[self setEphemText:[[Ephemerides alloc] initWithName:[infoText objectAtIndex:16]
qq:[[infoText objectAtIndex:6] doubleValue]
e:[[infoText objectAtIndex:7] doubleValue]
w:[[infoText objectAtIndex:8] doubleValue]
om:[[infoText objectAtIndex:9] doubleValue]
I:[[infoText objectAtIndex:10] doubleValue]
yr_peri:[[infoText objectAtIndex:3] doubleValue]
mo_peri:[[infoText objectAtIndex:4] doubleValue]
day_peri:[[infoText objectAtIndex:5] doubleValue]
abs_mag:[[infoText objectAtIndex:14] doubleValue]
mag_n:[[infoText objectAtIndex:15] doubleValue]
coord:coordRA
steps:numberSteps
interval:numberInterval]];
[self setTableDataSource:ephemText];
[self.infoTable reloadData];
infoText is an array that is loaded from a SQLite table prior to this and contains the necessary variables for the Ephemerides class to do the calculations.
Whenever I load that view controller in the app, I get this from Instruments:
Code:
# Address Category Event Type RefCt Timestamp Size Responsible Library Responsible Caller
0 0xa9399e0 Ephemerides Malloc 1 00:08.502.430 16 Comet -[CometEphem getEphemerides]
I do have [Ephemerides release]; and [ephemText release]; in my dealloc. That does not seem to help any. If I comment out the section of code shown above, then the memory leak goes away. So I am pretty certain that the problem is with that section of code.
I am relatively new to Xcode, but I understand the concepts of releasing memory. When I run my app in the simulator this is the only leak I have and I just can't figure out how to resolve it. Each time that controller loads I get another 16 bytes. My guess is that I should be going a about calling the Ephemerides class differently. Any help or direction would be greatly appreciated.
Keith