Re: setApplicationIconImage:
Got it Jens and thanks everyone for the help it’s much appreciated… :-) On Jan 24, 2015, at 1:05 AM, Jens Alfke j...@mooseyard.com wrote: On Jan 23, 2015, at 1:53 AM, Rick C. rickcort...@gmail.com mailto:rickcort...@gmail.com wrote: Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… What you're asking for is impossible, because -setApplicationIconImage is a TEMPORARY change to the icon that only takes effect when the method is called, and goes away when the app quits. Read that word again: TEMPORARY. We explained this to you already. If you ask questions and then ignore the answers, it makes people less likely to help you in the future. :-p —Jens ___ 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
Re: setApplicationIconImage:
On 1/23/15 18:00, cocoa-dev-requ...@lists.apple.com wrote: Date: Fri, 23 Jan 2015 09:05:54 -0800 From: Jens Alfke j...@mooseyard.com To: Rick C. rickcort...@gmail.com Cc: Cocoa Cocoa-Dev cocoa-dev@lists.apple.com On Jan 23, 2015, at 1:53 AM, Rick C. rickcort...@gmail.com wrote: Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… What you're asking for is impossible, because -setApplicationIconImage is a TEMPORARY change to the icon that only takes effect when the method is called, and goes away when the app quits. Read that word again: TEMPORARY. Just to complement this for the list archives, setApplicationIconImage: changes the _process_ icon in the Dock, not the _bundle_ icon in the application itself. The method should, perhaps, be called setProcessIconImage: :-) -- Rainer Brockerhoff rai...@brockerhoff.net Belo Horizonte, Brazil In the affairs of others even fools are wise In their own business even sages err. http://brockerhoff.net/blog/ ___ 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
Re: setApplicationIconImage:
On Jan 23, 2015, at 1:53 AM, Rick C. rickcort...@gmail.com wrote: Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… What you're asking for is impossible, because -setApplicationIconImage is a TEMPORARY change to the icon that only takes effect when the method is called, and goes away when the app quits. Read that word again: TEMPORARY. We explained this to you already. If you ask questions and then ignore the answers, it makes people less likely to help you in the future. :-p —Jens ___ 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
Re: setApplicationIconImage:
Rick, I have a silly suggestion you might like. I don't really understand what could be so different about the Yosemite icon that it would seem glaringly out of place on other systems, but assuming it really is the case that you want to continue to have two versions, I suggest you continue to use setApplicationIconImage:, but do things the other way around. Make the Yosemite icon be the app's official one, and only call setApplicationIconImage: for earlier OS versions. That way any unpleasantness will cure itself when the user upgrades. You might even include a preference setting so that if the change offends someone, he can turn it off and keep the Yosemite icon on any OS version. -- Charles On January 23, 2015 at 04:55:56, Rick C. (rickcort...@gmail.com) wrote: Thanks everyone for the help. Bit of effort for something simple though. Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… On Jan 23, 2015, at 11:09 AM, Charles Srstka cocoa...@charlessoft.com wrote: I think you should be able to do what you want using a Dock Tile Plugin: https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html Definitely don’t modify your app’s own bundle. Not only is that evil, but it’ll invalidate your code signature. Charles On Jan 21, 2015, at 11:46 PM, Rick C. rickcort...@gmail.com mailto:rickcort...@gmail.com wrote: Hi, I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com This email sent to cocoa...@charlessoft.com ___ 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/cejwork%40gmail.com This email sent to cejw...@gmail.com ___ 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
Re: setApplicationIconImage:
Thanks everyone for the help. Bit of effort for something simple though. Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… On Jan 23, 2015, at 11:09 AM, Charles Srstka cocoa...@charlessoft.com wrote: I think you should be able to do what you want using a Dock Tile Plugin: https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html Definitely don’t modify your app’s own bundle. Not only is that evil, but it’ll invalidate your code signature. Charles On Jan 21, 2015, at 11:46 PM, Rick C. rickcort...@gmail.com mailto:rickcort...@gmail.com wrote: Hi, I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com This email sent to cocoa...@charlessoft.com ___ 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
Re: setApplicationIconImage:
On Jan 23, 2015, at 07:34:19, Charles Jenkins cejw...@gmail.com wrote: Rick, I have a silly suggestion you might like. I don't really understand what could be so different about the Yosemite icon that it would seem glaringly out of place on other systems, but assuming it really is the case that you want to continue to have two versions, I suggest you continue to use setApplicationIconImage:, but do things the other way around. Make the Yosemite icon be the app's official one, and only call setApplicationIconImage: for earlier OS versions. That way any unpleasantness will cure itself when the user upgrades. You might even include a preference setting so that if the change offends someone, he can turn it off and keep the Yosemite icon on any OS version. The problem with setApplicationIconImage: is that it will revert back to the actual icon when the user quits, right? So if they keep the app in their Dock, the icon will keep changing as they launch/quit. -setIcon:forFile:options: still sounds like your best bet, because it will make a lasting change. Although it's too bad that Apple didn't allow this method to take an .icns file as well as an image. That would've made it the perfect solution. -- Steve Mills Drummer, Mac geek ___ 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
Re: setApplicationIconImage:
On 23 Jan 2015, at 10:07 AM, Steve Mills sjmi...@mac.com wrote: -setIcon:forFile:options: still sounds like your best bet, because it will make a lasting change. Although it's too bad that Apple didn't allow this method to take an .icns file as well as an image. That would've made it the perfect solution. For my own instruction, does it help that NSImage can take TIFF, which can be multi-resolution, which I suppose is what you wanted from .icns? It’s what Apple advocates for high-resolution within OS X apps, but I’d like to know whether the setIcon: pipeline makes that infeasible. — F ___ 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
Re: setApplicationIconImage:
On 22 Jan 2015, at 08:32, Allan Odgaard lists+cocoa-...@simplit.com wrote: For this to work, you need to exclude the Info.plist from the app bundle’s signature. Sounds like an exploit waiting to happen, though... If the OP insists on adapting the icon to the current OS version then I suggest using the existing system for custom icons. This works by writing a file named `Icon\r` to the root of the application bundle and should be easy to simulate in code. A quick test shows no need for resetting the LS cache, but you do need to relaunch Dock.app (for the dock to update). AFAIK there’s one more step: You need to set the “custom icon” bit on the .app directory (e.g. using the SetFile command line tool). But yeah, as this is something a user can do on the app in Finder, all this needs is permissions. No leaving a huge gap in your signature (or leaving it away completely — don’t even think about signing again on the user’s machine, that defeats the whole purpose of code signing). But anyway, NSWorkspace has a method for adding custom icons to a file: -setIcon:forFile:options: that would probably be the most convenient to use. Cheers, -- Uli Kusterer “The Witnesses of TeachText are everywhere...” http://zathras.de ___ 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
Re: setApplicationIconImage:
I think you should be able to do what you want using a Dock Tile Plugin: https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html Definitely don’t modify your app’s own bundle. Not only is that evil, but it’ll invalidate your code signature. Charles On Jan 21, 2015, at 11:46 PM, Rick C. rickcort...@gmail.com wrote: Hi, I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? ___ 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/cocoadev%40charlessoft.com This email sent to cocoa...@charlessoft.com ___ 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
setApplicationIconImage:
Hi, I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? ___ 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
Re: setApplicationIconImage:
On Jan 21, 2015, at 9:46 PM, Rick C. rickcort...@gmail.com wrote: I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? That method just temporarily alters the displayed icon while the app is running. It's used for things like badging, or the dynamic CPU meter display in Activity Monitor. There's no way that I know of to persistently change the app's icon, short of replacing the actual icon files in the bundle. —Jens ___ 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
Re: setApplicationIconImage:
Thanks for the reply. But how can I have multiple icon files in the bundle and then choose the one I want? On Jan 22, 2015, at 2:00 PM, Jens Alfke j...@mooseyard.com wrote: On Jan 21, 2015, at 9:46 PM, Rick C. rickcort...@gmail.com mailto:rickcort...@gmail.com wrote: I’m using NSApp setApplicationIconImage: to set a different icon for Yosemite. Problem is the standard icon appears for a second then it changes to the Yosemite one. Same when quitting the app. Is there a better way to do this? That method just temporarily alters the displayed icon while the app is running. It's used for things like badging, or the dynamic CPU meter display in Activity Monitor. There's no way that I know of to persistently change the app's icon, short of replacing the actual icon files in the bundle. —Jens ___ 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
Re: setApplicationIconImage:
On Jan 21, 2015, at 11:03 PM, Rick C. rickcort...@gmail.com wrote: Thanks for the reply. But how can I have multiple icon files in the bundle and then choose the one I want? Alter the app's Info.plist, I suppose (and then call LaunchServices to tell it to re-register, so it'll notice the changes.) Which is a really ugly thing to do — apps should _not_ be self-modifying. And it may often require administrator access because the user may not have write access to the app. I guess another possibility is to have an installer that writes the correct icon as the app is installed. But installers suck. Just leave it alone, is my advice. It's not worth the trouble just to try to make your app fit in. Change the icon to Yosemite style, and when users complain tell them to upgrade their OS to match it. —Jens ___ 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
Re: setApplicationIconImage:
On 22 Jan 2015, at 14:11, Jens Alfke wrote: Alter the app's Info.plist, I suppose (and then call LaunchServices to tell it to re-register, so it'll notice the changes.) For this to work, you need to exclude the Info.plist from the app bundle’s signature. If the OP insists on adapting the icon to the current OS version then I suggest using the existing system for custom icons. This works by writing a file named `Icon\r` to the root of the application bundle and should be easy to simulate in code. A quick test shows no need for resetting the LS cache, but you do need to relaunch Dock.app (for the dock to update). ___ 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
Re: setApplicationIconImage:
On Thu, Jan 22, 2015, at 01:03 AM, Rick C. wrote: Thanks for the reply. But how can I have multiple icon files in the bundle and then choose the one I want? You can't. --Kyle Sluder ___ 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
Re: Does [NSApp setApplicationIconImage] leak memory?
On Sat, 9 Aug 2008 15:19:08 -0700, Shawn Erickson [EMAIL PROTECTED] said: On Sat, Aug 9, 2008 at 2:46 PM, Mark Allan [EMAIL PROTECTED] wrote: I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]] but it obviously does function differently. Please post a complete code example that shows the original issue. I assure you the change that you stated that corrected the issue isn't the thing that corrected (of course you have only been posting partial code snippets and descriptions so we don't have the full context). Also it might be useful to state how you know there is or is not a leak in the first place. Is the phenomenon truly that an object remains incorrectly in memory as revealed by Shark or MallocDebug or similar - and if so, what object? - or is it merely intuition based on a high-level virtual memory measurement like Activity Monitor? m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide - Second Edition! http://www.amazon.com/gp/product/0596102119 ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; Okay, sorry for jumping in late, but I don't understand how this would solve the problem. Since we're talking about NSApplication, AppKit has already created an NSAutoreleasePool, so it's not like -setApplicationIconImage: is autoreleasing an object when there's no autorelease pool stack. Therefore, regardless of whether it's an AppKit autorelease pool or your own autorelease pool, any autoreleased object will still only get one -release message. Creating your own autorelease pool should only make it happen now instead of later. --Kyle Sluder ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On or about 8/10/08 4:37 PM, thus spake Kyle Sluder [EMAIL PROTECTED]: On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; Okay, sorry for jumping in late, but I don't understand how this would solve the problem. Since we're talking about NSApplication, AppKit has already created an NSAutoreleasePool, so it's not like -setApplicationIconImage: is autoreleasing an object when there's no autorelease pool stack. Therefore, regardless of whether it's an AppKit autorelease pool or your own autorelease pool, any autoreleased object will still only get one -release message. Creating your own autorelease pool should only make it happen now instead of later. That's perhaps perfectly true. But later could be a LOT later - and in the meantime quite a lot of memory could pile up. For example, it is the nature of the Cocoa event loop that the autorelease pool gets cleaned out when the user switches to another app and back to your app. But that might not happen for quite some time. To cite an example in my own life, in an app where I was creating a lot of autoreleased strings as I gathered data from a huge MySQL database, I actually caused my computer to freeze up for lack of memory. When I created my own autorelease pool and released it every n times thru the loop, the problem went away. This is, indeed, an *extremely* common technique for doing exactly what you say - making it happen now. You can read up on Cocoa memory management here: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concept s/AutoreleasePools.html Notice in particular this phrase: If you write a loop that creates many temporary objects, you may create an autorelease pool inside the loop to dispose of those objects before the next iteration. This can help reduce the maximum memory footprint of the application. So, to resume, it may in fact be that the OP's app is NOT truly leaking - but rather, that exactly what I'm describing here is what's happening to him: the built-in autorelease pool is just piling up and not getting released, because the event loop hasn't exited yet. The fact that the problem he is seeing does in fact go away for him when he does what I suggested is an indication that it is. This is one of the possible conclusions towards which, in my Socratic little way, I'm trying to lead the OP. Stay tuned. m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b Take Control of Customizing Leopard, http://tinyurl.com/2t9629 TidBITS, Mac news and reviews since 1990, http://www.tidbits.com ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Sun, Aug 10, 2008 at 8:04 PM, Matt Neuburg [EMAIL PROTECTED] wrote: That's perhaps perfectly true. But later could be a LOT later - and in the meantime quite a lot of memory could pile up. For example, it is the nature of the Cocoa event loop that the autorelease pool gets cleaned out when the user switches to another app and back to your app. But that might not happen for quite some time. I was under the impression that Cocoa flushed the top autorelease pool at the top of the runloop. But this is an Implementation Detail, after all. To cite an example in my own life, in an app where I was creating a lot of autoreleased strings as I gathered data from a huge MySQL database, I actually caused my computer to freeze up for lack of memory. When I created my own autorelease pool and released it every n times thru the loop, the problem went away. This is, indeed, an *extremely* common technique for doing exactly what you say - making it happen now. Believe me, I'm very familiar with this technique. I have an app that draws a lot of little rounded rectangles, and it's important that I don't just create a ton of autoreleased NSBezierPaths, but instead explicitly alloc and release them. Otherwise my working set grows dramatically. So, to resume, it may in fact be that the OP's app is NOT truly leaking - but rather, that exactly what I'm describing here is what's happening to him: the built-in autorelease pool is just piling up and not getting released, because the event loop hasn't exited yet. The fact that the problem he is seeing does in fact go away for him when he does what I suggested is an indication that it is. This is one of the possible conclusions towards which, in my Socratic little way, I'm trying to lead the OP. Stay tuned. m. Or maybe it has something to do with him explicitly retaining the autoreleased NSArrays he's creating, and inappropriately using usleep instead of an NSTimer... --Kyle Sluder ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, Aug 8, 2008 at 6:48 PM, Mark Allan [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. Sorry, I should have said in my original message that I'd already tried that, and the autorelease pool did solve the problem. It's just that doing this hundreds (possibly thousands) of times until my process is finished seems horribly inefficient. Do you know if it's actually a leak or if it's like that by design? http://www.mikeash.com/?page=pyblog/autorelease-is-fast.html In short, the cost of creating and destroying an NSAutoreleasePool is about the same as the cost of creating and destroying two NSObjects. It is extremely rare that the cost of a pool is noticeable against the other stuff that your code is doing. Mike ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, 8 Aug 2008 23:53:08 +0100, Mark Allan [EMAIL PROTECTED] said: On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. Sorry, I should have said in my original message that I'd already tried that, and the autorelease pool did solve the problem. Yes, that sure would have been a nice thing to do. At 6:24 pm -0400 08/08/2008, Sumner Trammell wrote: Is the need for the autorelease pool because of the use of setApplicationIconImage, or because of the array that is being used in conjunction with setApplicationIconImage? Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools. Really? Can you explain what removing the array from the equation has to do with the memory behavior you're seeing? m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide - Second Edition! http://www.amazon.com/gp/product/0596102119 ___ 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: Does [NSApp setApplicationIconImage] leak memory?
Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools. Really? Can you explain what removing the array from the equation has to do with the memory behavior you're seeing? m. No, sadly I can't explain it, but it does prevent the memory from leaking. I changed my initialiser calls from NSArray *imageX = [[NSArray arrayWithObjects: [NSImage imageNamed:@menu_frame1], [NSImage imageNamed:@dock_frame1], nil] retain]; to NSImage *dockImageX = [[NSImage imageNamed:@dock_frame1] retain]; and for each frame of the animation, I'm passing that NSImage directly to the [NSApp setApplicationIconImage:theNewImage] call. Even without the autorelease pools, the app's memory usage now stays constant after the first animation of all 8 frames. I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]] but it obviously does function differently. Mark ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Sat, Aug 9, 2008 at 2:46 PM, Mark Allan [EMAIL PROTECTED] wrote: I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]] but it obviously does function differently. Please post a complete code example that shows the original issue. I assure you the change that you stated that corrected the issue isn't the thing that corrected (of course you have only been posting partial code snippets and descriptions so we don't have the full context). -Shawn ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide - Second Edition! http://www.amazon.com/gp/product/0596102119 ___ 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: Does [NSApp setApplicationIconImage] leak memory?
Ok, stupid question time. 1. Is the need for the autorelease pool because of the use of setApplicationIconImage, or because of the array that is being used in conjunction with setApplicationIconImage? 2. Would putting the calls to setApplicationIconImage in a class method also stop the memory leak? Thanks, -s On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide - Second Edition! http://www.amazon.com/gp/product/0596102119 ___ 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/sumner.trammell%40gmail.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: Does [NSApp setApplicationIconImage] leak memory?
On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. Sorry, I should have said in my original message that I'd already tried that, and the autorelease pool did solve the problem. It's just that doing this hundreds (possibly thousands) of times until my process is finished seems horribly inefficient. Do you know if it's actually a leak or if it's like that by design? ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. m. At 6:24 pm -0400 08/08/2008, Sumner Trammell wrote: Ok, stupid question time. 1. Is the need for the autorelease pool because of the use of setApplicationIconImage, or because of the array that is being used in conjunction with setApplicationIconImage? 2. Would putting the calls to setApplicationIconImage in a class method also stop the memory leak? Thanks, -s Certainly not a stupid question, in fact, now *I* feel stupid for not trying that first suggestion earlier. Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools. Thanks guys. M ___ 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]