Re: Bound array item is repeatedly copied and collected while scrolling table view
... I noticed that, while I scrolled in the tableview, many copies of these large objects were being created and then immediately collected. ... NSCells used to display table content copies the object it display. Instead of binding the cell value to your object directly, bind it to its description or an other relevant property. Thanks for this suggestion, which clarifies things a bit. I thought about binding to 'description', but I want to be able to edit items in the table view when appropriate (it is not for my dataset object). I use the 'editable' binding to prevent edits to complex objects which shouldn't be edited in a collection view. Cheers, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bound array item is repeatedly copied and collected while scrolling table view
Le 7 juil. 09 à 14:24, Rick Hoge a écrit : I have a nib file in which entries in an NSTableView are bound to an NSMutableArray via an NSArrayController. It is used in an application running under garbage collection. The array items are NSDictionaries, and one of these dictionaries contains a large dataset object that consumes a lot of memory. I noticed that, while I scrolled in the tableview, many copies of these large objects were being created and then immediately collected. This might have something to do with the way that proxy objects are used by the array controller, or perhaps it is because the 'dataset' object is itself an entry in one of the table columns (presenting the string generated by the default 'description' method). Either way, this is detrimental to performance and memory footprint since these objects are huge (and I wouldn't normally have expected or wanted them to be copied). Is there any way to control this behavior, for example forcing the actual object to be used instead of these transient copies? Failing that, I am wondering (yes, I know this is ugly) if there is a way to set up some kind of context flag so that my object's 'copy' methods will just return a lightweight proxy when being called in this kind of situation (copied as part of a dictionary that is itself being copied)? The 'dataset' object implements both mutable and immutable copying. It is the 'immutable' copy method that is called during table scrolling. Thanks for any insight someone can offer, Rick NSCells used to display table content copies the object it display. Instead of binding the cell value to your object directly, bind it to its description or an other relevant property. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bound array item is repeatedly copied and collected while scrolling table view
... The array items are NSDictionaries, and one of these dictionaries contains a large dataset object that consumes a lot of memory. I noticed that, while I scrolled in the tableview, many copies of these large objects were being created and then immediately collected. It's not the table view's fault. What generates the description for the data set? You wrote a 'description' method? How long is the string it returns? If the property to which a table column is bound has the "copy" attribute, then the value will indeed be copied every time the table view fetches a value for the column. Does you "large dataset object" support NSCopying? However, since you've chosen to use dictionary instead of real properties, this seems unlikely to be the cause of your problem, unless there's more you haven't told us. My bet's on a giant description string the size of Manhattan. No - I don't override 'description' for my dataset class. The string presumably generated by NSObject's description method is displayed. My NLVolumeDataset does indeed support both NSCopying and NSMutableCopying. I know that this class's copyWithZone: method is called, and then very shortly thereafter 'finalize' is called. So it (the NSArrayController?) just seems to be firing off these huge copies so that it can call 'description' on them to display in the table, then discarding them. I agree it's not the table view's fault - it's just that even scrolling the table slightly so that the NLVolumeDataset entry comes in and out of view leads to the generation of large numbers of new copies. Thanks for the comments, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rickhoge1%40mac.com This email sent to rickho...@mac.com (43092.6825) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bound array item is repeatedly copied and collected while scrolling table view
On Jul 7, 2009, at 05:24, Rick Hoge wrote: I have a nib file in which entries in an NSTableView are bound to an NSMutableArray via an NSArrayController. It is used in an application running under garbage collection. The array items are NSDictionaries, and one of these dictionaries contains a large dataset object that consumes a lot of memory. I noticed that, while I scrolled in the tableview, many copies of these large objects were being created and then immediately collected. This might have something to do with the way that proxy objects are used by the array controller, or perhaps it is because the 'dataset' object is itself an entry in one of the table columns (presenting the string generated by the default 'description' method). Either way, this is detrimental to performance and memory footprint since these objects are huge (and I wouldn't normally have expected or wanted them to be copied). Is there any way to control this behavior, for example forcing the actual object to be used instead of these transient copies? Failing that, I am wondering (yes, I know this is ugly) if there is a way to set up some kind of context flag so that my object's 'copy' methods will just return a lightweight proxy when being called in this kind of situation (copied as part of a dictionary that is itself being copied)? The 'dataset' object implements both mutable and immutable copying. It is the 'immutable' copy method that is called during table scrolling. It's not the table view's fault. What generates the description for the data set? You wrote a 'description' method? How long is the string it returns? If the property to which a table column is bound has the "copy" attribute, then the value will indeed be copied every time the table view fetches a value for the column. Does you "large dataset object" support NSCopying? However, since you've chosen to use dictionary instead of real properties, this seems unlikely to be the cause of your problem, unless there's more you haven't told us. My bet's on a giant description string the size of Manhattan. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Bound array item is repeatedly copied and collected while scrolling table view
I have a nib file in which entries in an NSTableView are bound to an NSMutableArray via an NSArrayController. It is used in an application running under garbage collection. The array items are NSDictionaries, and one of these dictionaries contains a large dataset object that consumes a lot of memory. I noticed that, while I scrolled in the tableview, many copies of these large objects were being created and then immediately collected. This might have something to do with the way that proxy objects are used by the array controller, or perhaps it is because the 'dataset' object is itself an entry in one of the table columns (presenting the string generated by the default 'description' method). Either way, this is detrimental to performance and memory footprint since these objects are huge (and I wouldn't normally have expected or wanted them to be copied). Is there any way to control this behavior, for example forcing the actual object to be used instead of these transient copies? Failing that, I am wondering (yes, I know this is ugly) if there is a way to set up some kind of context flag so that my object's 'copy' methods will just return a lightweight proxy when being called in this kind of situation (copied as part of a dictionary that is itself being copied)? The 'dataset' object implements both mutable and immutable copying. It is the 'immutable' copy method that is called during table scrolling. Thanks for any insight someone can offer, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com