Re: Core Data: inverse relationship not updated until next Run Loop

2010-03-11 Thread Frank Illenberger
 In using Core Data, I was under the impression that if I do this:
 
 [department addEmployeesObject:employee]  // department now has 1 employee
 [moc deleteObject:employee]
 
 Then department will end up with no employees, assuming that the inverse
 relationship is set correctly.
 
 But it turns out within the same run loop, if I inspect
 [department.employees count], then the value is 1. But in the next run loop,
 the value becomes 0, which is what it should be.
 
 Is my observation accurate or is something wrong?
 
 Deletes are propagated at the end of he current event, or at save time, 
 depending how the MOC is configured.

But you can call [moc processPendingChanges] directly after the delete to 
propagate the changes immediately. 

Frank
___

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


NSLocale and currency symbols

2010-03-04 Thread Frank Illenberger
Hi,

under Mac OS 10.6, an NSLocale seems to contain the information whether a 
currency symbol should be put before the amount or behind it, like in $100.00, 
or 100,00€. 
Sadly, I was not able to find a way to specify this using the NSLocale/CFLocale 
APIs. Is this a private piece of information? Does anybody know how I might 
create a locale with a defined currency symbol behavior?

Thanks and cheers.

Frank


___

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: Problem using my own managed object context

2010-02-07 Thread Frank Illenberger
Hello Gideon,

in contrast to the warnings in Apple's documentation, using a custom subclass 
of NSManagedObjectContext is fine and often necessary to enrich the context 
information of your managed objects. We have successfully using this technique 
for complex applications since the first version of CoreData. But you have to 
be aware that during a store migration - which is performed during a Save 
As... in NSPersistentDocument -  CoreData allocates its own temporary context 
which will always be of the class NSManagedObjectContext. I regard this as a 
conceptual bug in CoreData not being able to specify the context class used 
during a migration. But in most cases, the custom context logic and state is 
not needed during the migration so that a few isKindOfClass checks are 
sufficient to deal with the changing context class.
That said, your crash looks like you under-retain or over-relase your context. 
Have you tried using Instruments.app to record the retain/release history of 
the migration context? And by the way: Have you considered switching your app 
to garbage collection?

Cheers

Frank

Am 08.02.2010 um 00:42 schrieb Gideon King:

 I'm having a problem that shows up when I do a Save As on my core data based 
 app. Saving my document is fine, so long as I save under the same name 
 (either with a new document or one I have loaded), but when I do a save as, I 
 get the following error:
 
 malloc: *** error for object 0x114e74cb0: pointer being freed was not 
 allocated
 
 and the stack trace shows:
 
 #0  0x7fff813a811c in objc_msgSend ()
 #1  0x7fff81bed2ec in -[NSManagedObjectContext(_NSInternalAdditions) 
 _dispose:] ()
 #2  0x7fff81becfd2 in -[NSManagedObjectContext dealloc] ()
 #3  0x7fff81bdc0a3 in -[NSManagedObjectContext release] ()
 #4  0x7fff81eb1246 in _CFAutoreleasePoolPop ()
 #5  0x7fff85db22f8 in -[NSAutoreleasePool drain] ()
 #6  0x7fff81c30eb9 in -[NSPersistentStoreCoordinator 
 migratePersistentStore:toURL:options:withType:error:] ()
 #7  0x7fff84a817e2 in -[NSPersistentDocument 
 writeToURL:ofType:forSaveOperation:originalContentsURL:error:] ()
 #8  0x000100032409 in -[NMPersistentDocument 
 writeToURL:ofType:forSaveOperation:originalContentsURL:error:] 
 (self=0x100d5b050, _cmd=0x7fff84d2a59e, absoluteURL=0x119c2ee30, 
 typeName=0x100819d00, saveOperation=1, 
 absoluteOriginalContentsURL=0x100a12640, error=0x7fff5fbfdea8) at 
 /Users/gideon/Development/svn/trunk/mac/Source/NMPersistentDocument.m:306
 
 If I enable zombies, it shows 
 
 *** -[NSManagedObjectContext _processReferenceQueue:]: message sent to 
 deallocated instance 0x11ec0e6b0
 
 Now initially I thought the issue must be that I was not removing observers 
 or something like that (which may still be true), but the interesting thing 
 is that in my subclass of NSPersistentDocument, in the init method, I change 
 the managed object context to my own one as follows:
 
 NSPersistentStoreCoordinator *coordinator = [[self managedObjectContext] 
 persistentStoreCoordinator];
 NMManagedObjectContext *context = [[NMManagedObjectContext alloc] init];
 [context setPersistentStoreCoordinator:coordinator];
 [self setManagedObjectContext:context];
 [context release];
 
 ...but that is not reflected in the stack trace - it is always talking about 
 an ordinary NSManagedObjectContext. 
 
 So I think maybe there is a problem with me using my own custom managed 
 object context in this way, and perhaps when it migrates the persistent 
 store, maybe somewhere there it reverts to a standard managed object context 
 or something.
 
 Does this sound like a likely scenario? Or am I barking up the wrong tree?

___

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


Pasteboard file promises under 10.6

2010-01-04 Thread Frank Illenberger
Does anybody know how to get file promises working with the new pasteboard API 
in Snow Leopard?
When the dragging session in started, I put the following item onto the 
provided pasteboard:

NSPasteboardItem* item = [[NSPasteboardItem alloc] init];
[item setDataProvider:self forTypes:[NSArray 
arrayWithObject:(NSString*)kPasteboardTypeFileURLPromise]];
[item setString:@net.mycompany.mydocument 
forType:kPasteboardTypeFilePromiseContent];
[pboard writeObjects:[NSArray arrayWithObject:item]];

But when I drag my objects, the delegate method 
pasteboard:item:provideDataForType: is never called. 
If I use public.data instead of my custom UTI, I get the following output in 
the console:

Looked for HFSPromises on the pasteboard, but found none

Sadly, the system documentation does not provide any more clues.

Cheers

Frank






___

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


CoreData: Using to-may relationships in fetch request predicates

2009-08-21 Thread Frank Illenberger

Hi there,

in  the typical CoreData example, if I want to fetch all departments  
whose employees have a salary higher than a specified value, I will  
perform a fetch on the Department entity using a predicate with the  
following format:


ANY employees.salary  %@

This is working fine.
Now I want to fetch all departments whose employees fulfill the salary  
condition AND are born after a certain date. I would expect something  
like this to work:


ANY (employees.salary  %@ AND employees.dateOfBirth  %@

But it doesn't. Does anybody know if there is a way to use the ANY  
statement with more than one condition?


Cheers

Frank

___

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: CoreData: Using to-may relationships in fetch request predicates

2009-08-21 Thread Frank Illenberger

ANY (employees.salary  %@ AND employees.dateOfBirth  %@)

But it doesn't. Does anybody know if there is a way to use the ANY  
statement with more than one condition?


 Are you using the sqlite store type? ANY can't be used in a  
compound predicate (AND) with the sqlite store type.


Yes, I am using an sqlite store, but I tried it with the other store  
types and it did not work either. What would a working predicate look  
like for other store types?


 Solution: Use another store type (probably not an appealing option)  
or bring in the ANY side, then filter the employees.dateOfBirth in  
memory.
Sadly, in-memory filtering is not an option for it has to happen in a  
single fetch.


___

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: CoreData: Using to-may relationships in fetch request predicates

2009-08-21 Thread Frank Illenberger


Am 21.08.2009 um 17:49 schrieb I. Savant:


On Aug 21, 2009, at 11:31 AM, Frank Illenberger wrote:

Yes, I am using an sqlite store, but I tried it with the other  
store types and it did not work either. What would a working  
predicate look like for other store types?




 I didn't catch this at first, but you said you're fetching  
employees where employee.salary  If the target entity for your  
fetch is Employee, does Employee really have an attribute named  
employee? Are you sure you don't mean where salary ...?


I am fetching against the Departments entity. I want all departments  
whose employees (this is the to-many relationship) fulfill the two  
conditions.


Sadly, in-memory filtering is not an option for it has to happen in  
a single fetch.


 That you said this without explaining why leads me to suspect this  
isn't the case. Even if you have a hundred thousand employees, I  
can't see how in-memory filtering is not an option. Please explain.


Believe me. This is for a dynamic, customer extendable reporting  
solution where this logic has to fit into a single predicate.



___

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: Synthesized instance variables

2009-03-12 Thread Frank Illenberger

And what prevent you to simply declare the ivar in the interface
instead of letting the compiler generating it ?


I second Andreas. For most cases, the correct place to declare  
instance variables should be the .m file as they are an implementation  
detail and not part of the contract with the outside world using the  
class. The feature of non-fragile instance variables of the modern ABI  
should make this dream possible. Synthesizing already takes place on  
the .m side but I also do not know how to gain access to the actual  
synthesized instance variable in a custom getter. Using  
objc_getInstanceVariable is not a good alternative as it is far to  
slow for being used in an on-demand getter. I think, Andreas does not  
care whether it is theoretically possible for the outside world to  
access the memory of his instance variables. He merely does not want  
to cite them is the contract.
The Objective-C release notes mention the symbol format OBJC_IVAR_ 
$_ClassName.IvarName for ivars but the compiler does not seem to  
understand it.
Does anybody know a way to access synthesized instance variables  
without using the synthesized getter methods?
And why isn't there a way to explicitly declare instance variables in  
the .m file for the new runtime?


Cheers

Frank

___

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: Synthesized instance variables

2009-03-12 Thread Frank Illenberger
I second Andreas. For most cases, the correct place to declare  
instance variables should be the .m file as they are an  
implementation detail and not part of the contract with the outside  
world using the class. The feature of non-fragile instance  
variables of the modern ABI should make this dream possible.  
Synthesizing already takes place on the .m side but I also do not  
know how to gain access to the actual synthesized instance variable  
in a custom getter. Using objc_getInstanceVariable is not a good  
alternative as it is far to slow for being used in an on-demand  
getter. I think, Andreas does not care whether it is theoretically  
possible for the outside world to access the memory of his instance  
variables. He merely does not want to cite them is the contract.
The Objective-C release notes mention the symbol format OBJC_IVAR_ 
$_ClassName.IvarName for ivars but the compiler does not seem to  
understand it.
Does anybody know a way to access synthesized instance variables  
without using the synthesized getter methods?


You can't in the current compiler. A future compiler should fix  
that. Use explicit @private ivars in the meantime. An @private ivar  
should not be considered part of the contract - that's what @private  
means, enforced by compiler warnings and linker errors.



And why isn't there a way to explicitly declare instance variables  
in the .m file for the new runtime?


Three reasons: (1) there are some non-trivial design details to work  
out, (2) compiler-engineer-hours are limited, and (3) @private ivars  
are generally good enough.


Thanks for clarifying this. So I am looking forward to that new  
compiler, as I think, moving private ivars to the @implementation side  
will greatly enhance the conciseness of the @interface side.


Cheers

Frank

___

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: CoreData: Fetching object with maximum of property

2008-10-08 Thread Frank Illenberger

Hello Bill,

unfortunately, this predicate does not work. The max() function  
returns the maximum of its comma-separated arguments. For example:  
max(2,1,5) -- 5

This does not help in the search for a cross-object maximum.

Cheers

Frank

On Oct 8, 2008, at 5:42 AM, Bill Dudney wrote:


Hi Frank,

Sorry for not getting back sooner;

http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/Articles/pBNF.html#/ 
/apple_ref/doc/uid/TP40001796-217785


documents the BNF which is very cryptic but tells you everything  
that can be in the expression.


So something like this for the predicate;

@loanToValueRatio = max(loanToValueRatio)

should work but its been a while since I've messed with it. I did  
have somethign very similar to this working in a project I did last  
year.


I'm running off fallible memory here but I believe that the CD  
SQLite stuff will convert this to the proper SQL.


Good luck!

-bd-
http://bill.dudney.net/roller/objc

On Oct 7, 2008, at 6:04 AM, Frank Illenberger wrote:


Hi Bill,

I tried using predicates for this but did not succeed.
What would a predicate look like which finds the object of an  
entity with the maximum value for a property?


Frank

On Oct 7, 2008, at 1:08 PM, Bill Dudney wrote:


Hi Frank,

That and a whole lot more;

http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/predicates.html#/ 
/apple_ref/doc/uid/TP40001798


Good luck!

-bd-
http://bill.dudney.net/roller/objc

On Oct 7, 2008, at 3:49 AM, Frank Illenberger wrote:


Hi everybody,

does anybody know if CoreData under Leopard offers a way to fetch  
the object of an entity which the maximum of a certain property  
value, but without having to fetch all objects into memory?


Cheers

Frank


___

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/bdudney%40mac.com

This email sent to [EMAIL PROTECTED]








___

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 [EMAIL PROTECTED]


Re: CoreData: Fetching object with maximum of property

2008-10-07 Thread Frank Illenberger

Hello Negm-Awad,

thanks for helping. The idea with the fetch limit and the descending  
order solves my problem as I am using a SQLite store.


Cheers

Frank

On Oct 7, 2008, at 2:59 PM, Negm-Awad Amin wrote:


In contrast to Bill I think, that this is not possible with  
predicates. Why?


You want to get the maximum value of an attribute. Obviously this  
task includes the knowledge of all values stored in that attribute.  
So if Core Data should do that, there are two approaches:


a) Reading all attributes and compare it. This is, what you didn't  
want to do.

b) Delegate this task to the SQL store.

The second one is the solution. But predicates filters the  
attributes. They do not really aggregate them, even there are some  
aggregates available. These aggregates filters the source entity by  
resolving a relationship, but not by aggregating a min or max value.
*If there is a solution using predicates, I'm highly interested in  
it.*


However, there is another solution, that should work:
When you have an entity you can fetch the instances of the entity.  
And you can sort them by using a sort descriptor. And you can set a  
fetch limit. So simply create a fetch request, set the sort  
descriptor's key to the attribute and the sort descriptor's order to  
descending. Set the fetch limit to 1. Executing this fetch will lead  
to the instance with the value for that attribute.


AFAIK this sort descriptors and limits are passed to the sql store.  
So the SQL engine will do that work. (Anyway the SQL engine of  
course has to read every value.)



-bd-
http://bill.dudney.net/roller/objc

On Oct 7, 2008, at 3:49 AM, Frank Illenberger wrote:


Hi everybody,

does anybody know if CoreData under Leopard offers a way to fetch  
the object of an entity which the maximum of a certain property  
value, but without having to fetch all objects into memory?


Cheers

Frank

___

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 [EMAIL PROTECTED]


CoreData: Fetching object with maximum of property

2008-10-07 Thread Frank Illenberger

Hi everybody,

does anybody know if CoreData under Leopard offers a way to fetch the  
object of an entity which the maximum of a certain property value, but  
without having to fetch all objects into memory?


Cheers

Frank


___

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 [EMAIL PROTECTED]


Re: CoreData: Fetching object with maximum of property

2008-10-07 Thread Frank Illenberger

Hi Bill,

I tried using predicates for this but did not succeed.
What would a predicate look like which finds the object of an entity  
with the maximum value for a property?


Frank

On Oct 7, 2008, at 1:08 PM, Bill Dudney wrote:


Hi Frank,

That and a whole lot more;

http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/predicates.html#/ 
/apple_ref/doc/uid/TP40001798


Good luck!

-bd-
http://bill.dudney.net/roller/objc

On Oct 7, 2008, at 3:49 AM, Frank Illenberger wrote:


Hi everybody,

does anybody know if CoreData under Leopard offers a way to fetch  
the object of an entity which the maximum of a certain property  
value, but without having to fetch all objects into memory?


Cheers

Frank


___

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/bdudney%40mac.com

This email sent to [EMAIL PROTECTED]




___

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 [EMAIL PROTECTED]


Cocoa application running very slow under 64 bit

2008-09-11 Thread Frank Illenberger

Hi there,

I migrated an existing cocoa application to run under x86_64 with  
Xcode 3.1 / Mac OS 10.5.4. The app still runs fine under 32 bit but  
when started in x86_64 mode, it runs about 3-4 times slower.

A shark profile reveals the following hot traces:

8.9%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_Backtrace   
7.6%libobjc.A.dylib objc_addExceptionHandler
7.5%Unknown Library _CFDoExceptionOperation 

7.2%Unknown Library _NSAppKitLock   
1.5%Unknown Library  
-[NSView nextKeyView]
1.2%Unknown Library  
-[NSView _primitiveSetNextKeyView:]
0.8%Unknown Library  
+[NSControl cellClass] [unknown]   
0.7%Unknown Library 
-[NSCell setMnemonicLocation:]  
0.6%Unknown Library 
SetPlaceholderString
0.5%Unknown Library 
-[NSView previousKeyView]   
0.2%	Unknown Library	  		-[NSControl  
_setControlTextDelegateFromOld:toNew:]



These hot traces do not show up when I profile the app running under  
32 bit.


Does anybody know why a 64 bit app could be spending so much time in  
these methods?


Cheers

Frank

___

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 [EMAIL PROTECTED]


Re: Cocoa application running very slow under 64 bit

2008-09-11 Thread Frank Illenberger



Hi there,

I migrated an existing cocoa application to run under x86_64 with  
Xcode 3.1 / Mac OS 10.5.4. The app still runs fine under 32 bit but  
when started in x86_64 mode, it runs about 3-4 times slower.

A shark profile reveals the following hot traces:

8.9%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_Backtrace   
7.6%libobjc.A.dylib objc_addExceptionHandler
7.5%Unknown Library _CFDoExceptionOperation 

7.2%Unknown Library _NSAppKitLock   
1.5%Unknown Library  
-[NSView nextKeyView]
1.2%Unknown Library  
-[NSView _primitiveSetNextKeyView:]
0.8%Unknown Library  
+[NSControl cellClass] [unknown]   
0.7%Unknown Library 
-[NSCell setMnemonicLocation:]  
0.6%Unknown Library 
SetPlaceholderString
0.5%Unknown Library 
-[NSView previousKeyView]   
0.2%	Unknown Library	  		-[NSControl  
_setControlTextDelegateFromOld:toNew:]



These hot traces do not show up when I profile the app running  
under 32 bit.


Does anybody know why a 64 bit app could be spending so much time  
in these methods?




Is your program throwing a lots of exceptions ? The exception  
handling mechanism is not the same between 32 bits and 64 bits  
runtime. IIRC throwing an exception on the 64 bits runtime os a lot  
more than on the 32 bits one.
With the 64bits runtime, it will properly unwind the stack and call C 
++ dtor when needed (even if a pure objc program does not require  
it), but with the 32bits runtime, it's just a longjmp call.


I am not throwing any exceptions in my code. If there are any, they  
must get thrown from within the Cocoa frameworks. Is there a way to  
track this? I added breakpoints at


objc_exception_throw

and

 -[NSException initWithName:reason:userInfo:]

but they were not hit.

Cheers

Frank

___

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 [EMAIL PROTECTED]


Re: Cocoa application running very slow under 64 bit

2008-09-11 Thread Frank Illenberger


Am 11.09.2008 um 14:04 schrieb Jean-Daniel Dupas:



Le 11 sept. 08 à 13:01, Frank Illenberger a écrit :




Hi there,

I migrated an existing cocoa application to run under x86_64 with  
Xcode 3.1 / Mac OS 10.5.4. The app still runs fine under 32 bit  
but when started in x86_64 mode, it runs about 3-4 times slower.

A shark profile reveals the following hot traces:

8.9%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_Backtrace   
7.6%libobjc.A.dylib objc_addExceptionHandler
7.5%Unknown Library _CFDoExceptionOperation 

7.2%Unknown Library _NSAppKitLock   
1.5%Unknown Library  
-[NSView nextKeyView]
1.2%Unknown Library  
-[NSView _primitiveSetNextKeyView:]
0.8%Unknown Library  
+[NSControl cellClass] [unknown]   
0.7%Unknown Library 
-[NSCell setMnemonicLocation:]  
0.6%Unknown Library 
SetPlaceholderString
0.5%Unknown Library 
-[NSView previousKeyView]   
0.2%	Unknown Library	  		-[NSControl  
_setControlTextDelegateFromOld:toNew:]



These hot traces do not show up when I profile the app running  
under 32 bit.


Does anybody know why a 64 bit app could be spending so much time  
in these methods?




Is your program throwing a lots of exceptions ? The exception  
handling mechanism is not the same between 32 bits and 64 bits  
runtime. IIRC throwing an exception on the 64 bits runtime os a  
lot more than on the 32 bits one.
With the 64bits runtime, it will properly unwind the stack and  
call C++ dtor when needed (even if a pure objc program does not  
require it), but with the 32bits runtime, it's just a longjmp call.


I am not throwing any exceptions in my code. If there are any, they  
must get thrown from within the Cocoa frameworks. Is there a way to  
track this? I added breakpoints at


objc_exception_throw

and

-[NSException initWithName:reason:userInfo:]

but they were not hit.


You may try to add a break point on objc_addExceptionHandler to find  
where it is call.


I breaked at objc_addExceptionHandler and it gets called a lot. Here  
are some example traces:


#0  0x7fff8000ee72 in objc_addExceptionHandler ()
#1  0x7fff801db290 in _CFDoExceptionOperation ()
#2  0x7fff80f50d8a in _NSAppKitLock ()
#3  0x7fff80f4ecd3 in +[NSColor redColor] ()
#4  0x7fff80f4e5d5 in +[NSApplication initialize] ()

#0  0x7fff8000ee72 in objc_addExceptionHandler ()
#1  0x7fff801db290 in _CFDoExceptionOperation ()
#2  0x7fff80f50d8a in _NSAppKitLock ()
#3  0x7fff80f4ee88 in +[NSApplication sharedApplication] ()

#0  0x7fff8000ee72 in objc_addExceptionHandler ()
#1  0x7fff801db290 in _CFDoExceptionOperation ()
#2  0x7fff80f50d8a in _NSAppKitLock ()
#3  0x7fff81012dd3 in -[NSApplication(NSWindowCache)  
_findWindowUsingCache:] ()

#4  0x7fff80f8c20b in _DPSNextEvent ()
#5  0x7fff80f8b6ff in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()


I guess this is normal behavior as these are regular cocoa calls. But  
why does this consume so much CPU time?


Cheers

Frank


___

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 [EMAIL PROTECTED]


Re: Cocoa application running very slow under 64 bit

2008-09-11 Thread Frank Illenberger
As I understand it, try/catch blocks should be very fast (zero cost)  
in the 64 bit evironment. As I can't observe the generation of any  
exceptions, there has to be some other reason for the slow  
performance. I can't find any documentation about  
objc_addExceptionHandler, so I don't know if it is only called when  
there are exceptions. Telling from the Shark trace, I guess the time  
is spent generating backtraces. But for what purpose?



8.9%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_GetIPInfo   
7.6%libgcc_s.1.dylib_Unwind_Backtrace   
7.6%libobjc.A.dylib objc_addExceptionHandler
7.5%Unknown Library _CFDoExceptionOperation 

7.2%Unknown Library _NSAppKitLock   
1.5%Unknown Library  
-[NSView nextKeyView]
1.2%Unknown Library  
-[NSView _primitiveSetNextKeyView:]


Am 11.09.2008 um 15:07 schrieb Matt Gough:



On 11 Sep 2008, at 14:49, Frank Illenberger wrote:

I breaked at objc_addExceptionHandler and it gets called a lot.  
Here are some example traces:


...

I guess this is normal behavior as these are regular cocoa calls.  
But why does this consume so much CPU time?


Cheers



Dunno, maybe now that the Obj-C exception ABI is the same as the C++  
one for 64-bit apps, there is a lot of extra stuff that needs  
preparing in case the exception is going to be caught by some C++  
code.


Matt


___

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 [EMAIL PROTECTED]


Re: Cocoa application running very slow under 64 bit

2008-09-11 Thread Frank Illenberger


Am 11.09.2008 um 18:15 schrieb Bill Bumgarner:


On Sep 11, 2008, at 8:47 AM, Frank Illenberger wrote:
As I understand it, try/catch blocks should be very fast (zero  
cost) in the 64 bit evironment. As I can't observe the generation  
of any exceptions, there has to be some other reason for the slow  
performance. I can't find any documentation about  
objc_addExceptionHandler, so I don't know if it is only called when  
there are exceptions. Telling from the Shark trace, I guess the  
time is spent generating backtraces. But for what purpose?


A little more information.

C++ exceptions and, under the modern ABI, Objective-C exceptions are  
extremely cheap to set up (@try), but expensive to @throw and @catch.


When the @throw happens, there is a heavy cost to generating the  
bits necessary to properly unwind the stack.


Unfortunately, the AppKit has an issue where it causes the unwind  
info to be generated as a normal part of its operation (without  
throwing an exception).


Thus, certain AppKit operations in 64 bit can be quite slow at this  
time.


Thanks for this important information. Is there any hope that this  
issue will be fixed for Leopard or should we hold back our 64 bit  
versions until Snow Leopard?


Cheers

Frank

___

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 [EMAIL PROTECTED]


Lenient NSNumberFormatters

2008-08-21 Thread Frank Illenberger

Hi there,

has anybody successfully used NSNumberFormatter's new setLenient:  
feature that was introduced with 10.5 together with one of the common  
number styles like currency or percent? As usual, I want the formatter  
to show a currency or percent symbol when turning numbers into strings  
but to be forgiving of omitted symbols when converting a user's string  
input into numbers.


The following code

NSNumberFormatter *percentFormatter = [[NSNumberFormatter alloc] init];
percentFormatter.formatterBehavior = NSNumberFormatterBehavior10_4;
percentFormatter.numberStyle = NSNumberFormatterPercentStyle;
[percentFormatter setLenient:YES];
NSLog(@%@, [percentFormatter numberFromString:@10]);

outputs (null).  The same happens with the currency style.

Is there any way to get a lenient behavior from NSNumberFormatter  
without having to subclass it?


Cheers

 Frank


___

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 [EMAIL PROTECTED]