Helium Foot Software

Making your Mac more agile, more powerful and more fun

February 2012
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
About
Helium Foot Software develops MercuryMover: Don't let the mouse slow you down! Move and resize windows on your Mac with the keyboard.
Recent Entries
GroceryList and Beyond(04/18 10:26)
Go, Go, GroceryList(01/28 21:53)
Indie+Relief(01/19 22:13)
One Fifth of a Five Fingered Discount(11/06 10:18)
On the Job, On the Train(10/30 12:09)
Hey Mac(10/21 10:38)
Dog Fed(10/15 09:53)
20 Questions(10/08 09:59)
A Gallon of Milk and an Onion(10/06 11:34)
The iPhone Doesn't Need Me(09/24 11:46)
Recent Comments
Recent Trackbacks
There are no trackbacks.
Categories
Helium Foot (28 items)
Software (5 items)
MercuryMover (37 items)
Blog (3 items)
MacSanta (3 items)
Marketing (12 items)
Philanthropy (2 items)
Podcasts (3 items)
Highbrow (3 items)
iPhone (1 items)
GroceryList (4 items)
Archives
Blogroll

Syndicate this site (XML)

RSS/RDF 0.91

02 January
2007

In the background

MyWi runs in the background as a faceless application (referred to by Apple's documentation, and heretofore as an "agent application") and brings up a minimal user interface when a hot key is typed. In order to have a good user experience, the UI absolutely has to come forward immediately. When using development builds of MyWi myself I was often having to wait for the window to appear, especially when all of my physical memory was in use. During the day, I'm a java developer for a small software company. In addition to eclipse, safari, mail, itunes, ical etc, I also have four additional java virtual machines running our application(s). Let's just say that this does not leave a lot of memory lying around to keep my agent out of the swap file. I was hoping that there was some way to keep my agent resident in physical memory, and lo and behold, there is. Daniel Waylonis pointed out the following thread to me from the core audio list in which the task_wire mach call is described. It was very easy to implement like so:

        #import <mach/vm_map.h>
        ...
        //stay resident in memory
        vm_map_t me = mach_task_self();
        kern_return_t code = task_wire(me, true);
        if (code == KERN_INVALID_HOST) {
                NSLog(@"vm_wire returned KERN_INVALID_HOST.\n");
        } else if (code) {
                NSLog(@"task_wire error code = %d.\n", code);
        } else {
                NSLog(@"task_wire(..., true) succeeded.\n");
        }

Now the UI usually comes up immediately. The first time I hit the hot key in the morning, it still takes a while to present the UI and I'll have to do some additional analysis to figure out why.

Posted by kalperin at 20:18
<< First Post | Main | The sound of Getting Things Done >>