Using objectIn<Key>AtIndex gobbling memory for autoreleased objects.
Using objectIn<Key>AtIndex gobbling memory for autoreleased objects.
- Subject: Using objectIn<Key>AtIndex gobbling memory for autoreleased objects.
- From: "Justin Drury" <email@hidden>
- Date: Tue, 15 Nov 2005 08:46:00 -0800
I'm having a wee bit of headache using the functions
objectIn<Key>AtIndex and countOf<Key>
I've created a small test project(link at bottom of email), basically my problem is I have data that isn't
in a format that can be easily used by Cocoa and bindings. In fact quite a few methods need be
called before the data is available, and these are being called in the objectIn<Key>AtIndex method.
Anyways using my simple example(returning an NSString*) here's the problem.
If I create an autoreleased object to return in the objectIn<Key> method, that object is not released
as the view contents change in response to user interaction, resulting memory usage climbing up
and up and up as data is browsed. In my example I've bound the property 'rows' to my table
-(id) objectInRowsAtIndex:(int) rowValue
{
return [NSString stringWithFormat:@"This is test string number :%i that'll gobble up
memory",rowValue];
}
Now if I launch MallocDebug and start moving the scrollview up and down, more and more objects
get allocated(the string), and nothing is released, memory just keeps climbing up and up, and things
get more and more sluggish. Eventually if I were to change the bound content the memory is
released from the tableview, but not until the contents have been cleared(or changed). There isn't
even a limit, I thought ok its caching the data, but it'll continue to climb up infinitely.
Now if I have a series of preallocated objects that are just returning by value
-(id) objectInRowsAtIndex:(int) rowValue
{
return [columnObject stringAtIndex:rowValue];
}
No problem at all. Unfortunately this isn't an option for me, as I need to generate the data on the
fly...
This seems to happen for everything I've tested so far( NSString / NSDictionary). Using the old
dataSource methods I'm able to return autoreleased objects with no problem, so I've had to abandon
bindings for a data provider in the interim. Iam I running into some sort of limitation here?
thanks for any help. I've been wrestling with this for a few hours!!!
Justin
xcode test project:
http://homepage.mac.com/soundminer/BindingGobble.zip
/***********************/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden