December 09, 2004

iChat/iSight and Postgres Memory Bug

I'm posting this on a blog entry, not because I think my loyal blog readers are going to be interested by it, but someone out there on the web might run into this issue, and some googling suggests that nobody has reported on it.

There were two strange software failures going on recently, both of them quite troublesome, and it took until today to realize they were directly related.

On the one hand, I noticed that three people (who now work distantly together) were having problems with iChat on their G5 computers. Basically, an attempt to initiate a video chat would die with a cryptic—and misleading—message: Disconnected from Video Chat because: Can't get video from the camera. The problem could only be solved by rebooting the computer.

There was another strange and inconsistent problem that just started happening, where Dave and I would not be able to start up Postgres due to a memory error: FATAL: could not create shared memory segment: Cannot allocate memory

The Postgres problem would occasionally pop up, and after the error showed up, there would be nothing short of rebooting that would alleviate the problem.

Well, the two problems appear to be related. If you have an iChat video chat, you will be able to run Postgres; and if you run the Postgres database, you will be unable to run iChat. The problem seems to lie with something called shared memory which is a section of memory that the Operating System manages that is able to be accessed by multiple processes.

Operating Systems generally have settings where you can specify the maximum amount of shared memory used, the maximum size of a shared memory segment, etc. In OS X these settings are the in file /etc/rc. Dave seems to have been able to fix the problem by increasing this maximum shared memory to 128 megabytes. (The default is 4!) I'm guessing you can have much less, but we haven't had the chance to do much testing yet.

One good resource is this page which has a comment on the very bottom by a Mac guy who makes specific recommendations for OS X. (Note, it's dated 2002, so it's a little stale.)

If you have any luck or feedback, please provide it in the comments below so others can benefit from your wisdom!

Posted by Murray Todd Williams at December 9, 2004 07:06 PM

Holy sh*t! I can't believe that this was the issue. I tried everything to try to get this working. All I had to do was shut down the pg database. Thanks so much for this page, I've been waiting months to resolve this problem. I'll try to post on apple discussion boards too. Any luck with more recent versions of Postgres?

Posted by: Jesse Costello-Good at January 3, 2005 02:39 PM

Or is it a port issue?

But I changed the port to 5433 and that didn't help.

Posted by: Jesse Costello-Good at January 3, 2005 09:02 PM


Thanks so much for posting this information! Your solution showed up in a google search. I had scoured the apple discussion boards looking for a fix.

I shutdown postgres and boom! My iSight camera works like a charm in iChat. I posted a followup on the appropriate discussion on the Apple boards. Thanks!

Posted by: Eric at January 29, 2005 06:12 AM

Been struggling with this one for a while... we thought it was our routers at first.

Thanks so much for this info!

Posted by: Ed at March 19, 2005 12:44 PM

I encountered this problem about a month ago on my Powerbook, and haven't been able to find a plausible cause for it until now.

Hope this will fix things when I get around to trying it.

Posted by: Audun Rundberg at May 8, 2005 01:14 PM

What a find! This problem affected both my Powerbook G4 and my G5 desktop. I was about to give up after tweaking firewall settings and trying everything else I could think of. Shutting down PostgreSQL worked perfectly.

I tried to increase my shared memory size, as recommended in one of the articles linked above. Didn't work for me, even when I increased from 4MB to 128MB. I am using OS X Tiger 10.4.1.

Posted by: Kurt at May 19, 2005 10:33 AM

WOAH! I would *never* have thought of that. Thank you thank you thank you thank you :D I was just about to take the iSight back to the store, as well ;) So not only has your insight helped me VChat with my wife and daughter again, but it also saved me a long and unnecessary walk, too :D

Posted by: Clive Jevons at June 1, 2005 12:43 AM

Does anybody know why? I can't believe that this is really true!
But often the things are not as they seem to be in this coloured world...

Posted by: Drake at June 10, 2005 04:30 AM

THANK YOU FOr this...... I would NEVER have put these two together.........

I was GOING BATTY reinstalling ichat and such.

THANK YOU!!!!!!!!!!

Posted by: Joe Fleck at June 18, 2005 10:15 AM

Another thing just for anyone who may not already know it. Apple Remote Desktop also uses Postgres for something (I can't remember what). For me the solution to this was to stop my sharing of my Desktop over ARD. That killed the Postgres processes and allowed the camera to finally connect. Quite strange that Apple wouldn't have isolated this problem being that two of their applications could be the ones causing the problem.

Posted by: Kris Hagel at June 24, 2005 08:57 AM


I have the same issue. Someone trying to connect from a hotel room to me. (Powerbook to iMac G5, both on 10.4.1). Audio works, video, does initiate and start, but then stops with the message: "Disconnected from Video Chat because: Can't get video from the camera. "
I don't know what Postgress is, and I don't understand how to increase shared memory. Can sombody help ?



Posted by: Serge de Gheldere at July 4, 2005 08:25 AM

I have the same issue and tried Murray's solution, which I incleased the shared memory's max to 128MB. However, the problem can't sold. I am using Mac OS X Tiger. Is that a problem?

Posted by: Yoshi at August 5, 2005 01:19 AM

Strange! killed the postmaster and sure enough it worked. Thanks for the heads-up. I had to increase shared memory to even get postgres running initially, as noted here:

Posted by: Brett at August 5, 2005 07:52 PM

I found Lotus Notes 6.5 on my powerbook causes the same error. Very strange.

Posted by: Ryan at August 9, 2005 05:06 PM

This problem is actually a long running problem with the port Postgres uses, 5432.
If you change Postgres to use 5431 (or something else that's free) in your config file this fixes it (the file is /usr/local/pgsql/data/postgresql.conf and you need to be root--search for 5432 in the file).
Note that you'll have to stop and restart postgres (or just restart the machine).
I can't believe that Apple won't change their port, since Postgres has been using the same port for years, long before iChat came on the scene.
One other note--you'll need to change your code in any apps that reference the port 5432 to reflect the new port. This can be a pain if you're developing on your machine and then putting it up on another machine for production, because you have to change that reference back to 5432 when you put it on another machine.

Posted by: Dave Mancuso at September 15, 2005 08:54 AM
Post a comment

Remember personal info?