Open GoogleCodeExporter opened 8 years ago
btw, same issue when call autorelease after init.
Original comment by wilsonli...@gmail.com
on 27 Mar 2010 at 4:03
Checed it again. This issue only happens on OS X system, not iPhone.
Original comment by wilsonli...@gmail.com
on 29 Mar 2010 at 2:50
Checed it again. This issue only happens on OS X system, not iPhone.
Original comment by wilsonli...@gmail.com
on 29 Mar 2010 at 2:50
I'm seeing this issue on the iPhone w/ the latest (pre-release) version of
iPhone SDK.
Original comment by trevor.r...@gmail.com
on 21 Jun 2010 at 12:48
Also seeing this in the test cases in running against 3.2 and 4.0 sdk's
Original comment by KingSqui...@gmail.com
on 5 Jul 2010 at 12:06
Also saw this while debugging on iPhone 3GS / iOS4, when calling +clearCache.
wilsonli.cn's fixing is working fine for me.
SQLitePersistentObject is setting itself as its observer in -(void)init.
http://code.google.com/p/sqlitepersistentobjects/source/browse/trunk/src/SQLiteP
ersistentObject.m#1310
So I think it is natural to do removeObserver in dealloc.
I haven't found official Apple doc that removing observers is necessary before
releasing, but here's a
stackoverflow thread that says so:
http://stackoverflow.com/questions/13927/in-cocoa-do-i-need-to-remove-an-object-
from-receiving-kvo-notifications-when-deal
Original comment by kenji.ta...@gmail.com
on 7 Jul 2010 at 2:01
I've fixed most of this crazy logging by doing this:
diff --git a/Lib/sqlpo/SQLitePersistentObject.m
b/Lib/sqlpo/SQLitePersistentObject.m
index 41d5c1b..5c6c264 100644
--- a/Lib/sqlpo/SQLitePersistentObject.m
+++ b/Lib/sqlpo/SQLitePersistentObject.m
@@ -219,7 +219,7 @@ NSMutableArray *checkedTables;
+(SQLitePersistentObject *)findByPK:(int)inPk
{
SQLitePersistentObject *ret = nil;
- NSString *k = [SQLitePersistentObject memoryMapKeyForObject:inPk];
+ NSString *k = [[self class] memoryMapKeyForObject:inPk];
if ([[objectMap allKeys] containsObject:k])
ret = [objectMap objectForKey:k];
if (ret == nil)
@@ -249,16 +249,14 @@ NSMutableArray *checkedTables;
while (sqlite3_step(statement) == SQLITE_ROW)
{
BOOL foundInMemory = NO;
- id oneItem = [[[self class] alloc] init];
+ int thePk = sqlite3_column_int(statement, 0);
+ NSString *mapKey = [[self class] memoryMapKeyForObject:thePk];
- [oneItem setPk:sqlite3_column_int(statement, 0)];
- NSString *mapKey = [oneItem memoryMapKey];
if ([[objectMap allKeys] containsObject:mapKey])
{
SQLitePersistentObject *testObject = [objectMap objectForKey:mapKey];
if (testObject != nil)
{
- [oneItem release];
[ret addObject: [testObject retain] ];
foundInMemory = YES;
}
@@ -267,6 +265,9 @@ NSMutableArray *checkedTables;
if(foundInMemory)
continue;
+ id oneItem = [[[self class] alloc] init];
+ [oneItem setPk:thePk];
+
where memoryMapKeyForObject is:
+ (NSString *)memoryMapKeyForObject:(NSInteger)thePK
{
return [NSString stringWithFormat:@"%@-%d", [self className], thePK];
}
---
The way the code was setup before would cause crashes on faster systems when
calling removeObserver:forKeyPath: in dealloc (this is not a good idea in
general).
Original comment by samuraib...@gmail.com
on 10 Jul 2010 at 12:09
It's also a good performance improvement. :)
Original comment by samuraib...@gmail.com
on 10 Jul 2010 at 4:05
[deleted comment]
[deleted comment]
@samurai Hey I had the same problem and your solution works perfectly thank you!
Original comment by spsriram...@gmail.com
on 21 Jan 2011 at 11:50
I have the same problem too! How do I apply that patch?
Original comment by tom.van....@gmail.com
on 23 Jan 2011 at 1:16
Happens in iOS 5 beta 6 for me.
Original comment by turfla...@gmail.com
on 1 Sep 2011 at 12:01
Original issue reported on code.google.com by
wilsonli...@gmail.com
on 27 Mar 2010 at 3:51