You probably have incompatible software running under launchd and it is crashing constantly.
Check your Console application (found in Utilities) and see if there are logs showing up.
For me, Livescribe Desktop is broken under Lion, I see the following filling my logs:
Jul 22 07:11:50 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Jul 22 07:12:00 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Jul 22 07:12:10 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Jul 22 07:12:20 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Jul 22 07:12:30 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Jul 22 07:12:30 Walkabout com.apple.launchd (PenCommService): Exited with code: 1
Jul 22 07:12:30 Walkabout com.apple.launchd (PenCommService): Throttling respawn: Will start in 10 seconds
Jul 22 07:12:40 Walkabout com.apple.launchd (PenCommService): getpwnam("_pencomm") failed
Over and over. This can spike CPU usage for the launchd. Probably something similar for opendirectoryd as well (there are known issues with network mounts in Lion (they changed netatalk to version 2.2, and most NAS servers are not compatible). You should be able to get more information in the logs, post them here for additional assistance.
I've seen opendirectoryd (and automountd) uses up around 100% for total of my CPU too. Fan keeps growling all the time probably due to those processes. They restart immediately after I "force quit" them.
On console message, I don't really see launchd related errors.
I just found that stopping dropbox (which was just waiting for the new changes. Data is already synchronized so it doesn't need to work so eagerly I guess) calms down those 2 processes.
So as a temporary workaround in my situation, I run dropbox only when I need.
So far I haven't found others claiming on dropbox' support community with exactly the same issue, this might not be that common issue?
MacBook 5.1, dropbox 1.1.35
I fixed this another way. I had opendirectoryd using 25-50% of CPU on a quard core Mac Pro running 10.7.1. No obvious messages in console.
The problem was that spotlight was confused. I added my main hard drive to Spotlight's 'Privacy' panel in System Preferences, and then removed it. This triggered my main hard drive to be reindexed by mds. After several hours of high CPU and disk use by mds, both opendirectoryd and mds are at low CPU usages.
Correction: The above is true, but high CPU use returned.
I had to totally rebuild the Spotlight database. To delete it, from terminal:
% sudo mdutil -E -a
Then, needed a full rebuild. I rebooted early on, and that confused mds, so I re-deleted and then left the computer on overnight. opendirectoryd no longer running incessantly.
I've tried what you suggested. Though I can't say it has fully resolved the issue since the 2 processes still bump at occasionally, someting has certainly changed. I'll keep observing. What I did was as you're suggesting: 1) add & remove the main drive at Spotlight's 'Privacy' panel, 2) Rebuild Spotlight's DB by running "% sudo mdutil -E -a", 3) keep Mac on for a day.
Thanks a lot!
I'm having the same problem. opendirectoryd is taking up 100% of my CPU and I think as a result it is draining the battery ridiculously fast. I have Dropbox but I turned it off and it does not solve the problem. When I check Console the only recurring log is one related to Outlook:
Microsoft Outlook: CFURLCreateWithString was passed this invalid URL string: '/EWS/Exchange.asmx' (a file system path instead of an URL string). The URL created will not work with most file URL functions.
I'm not sure if this is related or if it's a completely separate issue. Does anyone have any advice???
Previously, I had opendirectoryd taking up a lot of CPU. Another symptom was long/slow Spotlight backups. This slightly improved when I blocked some folders from being backed up, but still persisted. I also had previously moved my iTunes library to another drive.
Ultimately, I moved approx 1.5 million small files from my main drive to another drive that is not backed up by Time Machine.
That cut both opendirectoryd and spotlight backups back to a reasonable duration.