[Mysql-cocoa-users] Possible Memory leak in MCPConnection.m - MCP not autoreleased?
Brought to you by:
sergecohen
From: Jason M. <jas...@ya...> - 2003-11-15 21:02:26
|
Hi. I've been using the framework and it's excellent. But I've run into a problem which I think is caused by a memory leak... Basically, I'm writing a batch application that has to do thousands of inserts. In MCPConnection.m: - (MCPResult *) queryString:(NSString *) query { MCPResult *theResult = [MCPResult alloc]; /*****snip*****/ if ((theQueryCode = mysql_query(mConnection, theCQuery)) == NULL) { if (mysql_field_count(mConnection) != 0) { theResult = [theResult initWithMySQLPtr:mConnection encoding:mEncoding]; } else { // NSLog (@"Query worked but gives no output\n"); // [theResult init]; return nil; } } /*****snip*****/ It looks like theResult is alloc'd, but if the result is the empty set (like in an insert), nil is returned, but theResult is never autoreleased or released. I ran my program through ObjectAlloc and there are many MCPResults left over form my multiple inserts. They don't take up much space, but as I said, my program does thousands of inserts and they build up over time causing a crash. Let me know if I'm wrong here. But right now this looks like the major bug du jour in my program... Jason ===== Jason McInnes 2 Degrees Cell: 206.849.3680 Email: jas...@ya... __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree |