> On 3 May 2016, at 6:10 AM, Martin Wierschin <mar...@nisus.com> wrote:
> 
>> My app deals with an object tree that can have millions of leaves. It is 
>> possible to run an operation on all of them. Each will register its own 
>> change with the undo manager. 
> 
> Is it absolutely necessary for each leaf object to register its own undo 
> invocation? I don’t know if that’s the actual cause of your slowdown, but it 
> seems like a design to be avoided if possible. Can you instead capture a 
> single undo invocation for all affected objects? Even if you have to bundle 
> up and collect state information for all your millions of objects, having a 
> single undo invocation would likely be more efficient than millions of undo 
> invocations each with their own state information.



+1

The Undo Manager creates an NSInvocation object for every action that it 
records. That could add up to a massive memory load for a big tree with each 
node recording an action, as well as a significant performance hit.

As Martin suggests, you probably want to disable undo altogether around the big 
tree operation, enable it again afterwards, then record ONE undo task that can 
undo the entire tree operation. Many big structure designs include a “bulk 
load” operation for this sort of purpose.

—Graham



_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to