• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps


  • Subject: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
  • From: Peter Lübke <email@hidden>
  • Date: Thu, 11 Nov 2010 13:04:23 +0100



In my app, I call AXUIElementCopyAttributeNames() and AXUIElementCopyAttributeValue() very frequently, but as far as I can see, the resulting objects are all properly released and ObjectAlloc and MallocDebug show no indication of possible leaks

In your code, do you call CFRelease() on the attribute names and the attribute value when you are finished with them? The convention for Core Foundation functions like these is that, if the function contains the word "copy," you are responsible for CFReleasing the object. This applies to the accessibility functions.


To be exact, I do it like this:

// -valueForAttributeCopy:
// Returns an object typed id representing the value for a given attribute of the receiver's AXUIElement or nil if the attribute doesn't exist.
// The sender is responsible for releasing the object.
- (id)valueForAttributeCopy:(CFStringRef)attribute
{
id value = nil;
id axValue = nil;
NSArray *attrNames;


if (AXUIElementCopyAttributeNames((CFTypeRef)_element, (CFArrayRef *)&attrNames) == kAXErrorSuccess)
{
if ( [attrNames indexOfObject:(NSString *)attribute] != NSNotFound && AXUIElementCopyAttributeValue((CFTypeRef)_element, attribute, (CFTypeRef *)&axValue) == kAXErrorSuccess )
value = axValue;
}
[attrNames release];


return value;
}
(where _element is an instance variable with an AXUIElementRef, stored in my AXUIElement wrapper class object.)

In the calling method, I compare the returned object against the value I'm looking for and then release it by calling [value release].

Do you think it is bad practice to cast CFTypeRefs to type id and releasing them this way?
As I mentioned, ObjectAlloc tells me that my app doesn't accumulate memory allocations, while the other app does.
Or am I wrong in that my app is not able (and not allowed) to retain objects in another app's memory space?

Peter
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
      • From: Christiaan Hofman <email@hidden>
    • Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
  • Next by Date: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
  • Previous by thread: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
  • Next by thread: Re: Performance slowdown when traversing UIElements under menu bar of Mail and some other apps
  • Index(es):
    • Date
    • Thread