rtcontrib - setting maximum number of open files on OSX 10.6.8

My second question is for Radiance users running OSX. I'm having trouble setting the maximum number of open files to more than 1024. I'm running OSX 10.6.8, and there seems to be two ways to change the maximum number of open files - one using ulimit and one using launchctl.

In .bash_profile I have this line:

ulimit -S -n 4096

In etc/launchchd.conf I have this:

limit maxfiles 4096
sysctl -w kern.maxfiles=4096

and in etc/sysctl.conf I have:

kern.maxfiles=4096 kern.maxfilesperproc=4096

In a terminal line, when I enter launchctl limit I see this:

        cpu unlimited unlimited
        filesize unlimited unlimited
        data unlimited unlimited
        stack 8388608 67104768
        core 0 unlimited
        rss unlimited unlimited
        memlock unlimited unlimited
        maxproc 266 532
        maxfiles 4096 4096

Which is good. 4096 is more than the 2306 files I want rtcontrib to talk to at the same time.

But then, looking at ulimit -a in a terminal, I see this:

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 266
virtual memory (kbytes, -v) unlimited

Which is bad - 1024 is less than the 2306 files I want rtcontrib to talk to at the same time. Its also surprising given that it should be set to 4096 by .bash_profile.

Then when I try ulimit -n 4096, I get this:

bash: ulimit: open files: cannot modify limit: Operation not permitted

If I use sudo, it takes the command, but when I look at ulimit -a again, the open files limit still says 1024, and despite what launchctl limit says, 1024 is the governing number of maximum open files.

Has anyone out there had success setting this in OSX 10.6 or higher? Or has anyone updated to 10.7 (just released today) and had success?

Many thanks,
Michael