shuiyouren / sqlitepersistentobjects

Automatically exported from code.google.com/p/sqlitepersistentobjects
0 stars 0 forks source link

Any subclass with an NSString property leaks #64

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a subclass of SQLitePersistentObject
2. Add an NSString property to the class
3. Instantiate the class and release it immediately, observe the leak in 
Instruments

I'm using revision 134

Original issue reported on code.google.com by duplessi...@gmail.com on 30 Mar 2009 at 7:36

GoogleCodeExporter commented 8 years ago
I think I have found the solution.

After running it in Instruments, it seems that the call resolveClassMethod
SQLitePersistentObject.m is the leaky culprit.

For whatever reason the lines:
1222    NSString *methodBeingCalled = [[NSString alloc] 
initWithUTF8String:methodName];
1223    // NSString *methodBeingCalled = [NSString 
stringWithUTF8String:methodName];

SHOULD BE:
1222    // NSString *methodBeingCalled = [[NSString alloc] 
initWithUTF8String:methodName];
1223    NSString *methodBeingCalled = [NSString stringWithUTF8String:methodName];

Alternatively, you could also release methodBeingCalled at the end of the 
function. 

It seems to have been introduced in revision 121, but no explanation as to why 
the
autoreleased version was commented out and the retained version was used 
instead.

Hope a contributor reads this and puts this in the next revision check-in.

Original comment by jamesy...@gmail.com on 9 Apr 2009 at 1:48

GoogleCodeExporter commented 8 years ago
added your change to r135. Thanks.

Original comment by amle...@gmail.com on 9 Apr 2009 at 11:58