For what it's worth, I ended up encountering the problem on my system which serves a moderate amount of mail-users.
What I did is I did "apt-get install apachetop", which without asking me (what an arrogant package-manager), removed libfam0, even though courier-imap depended on it. So I did "apt-get install libfam0", and after that it still started okay (I think) - which removed apachetop. I ended up installing apachetop once more, to test around whether courier-imap would work without libfam0, but yet again re-installed libfam0 using apt-get to be safe, after which I got "xrealloc: ../bash/subst.c:512: cannot reallocate 512 bytes (0 bytes allocated)" when running /etc/init.d/courier-imap start. What I did is edit /etc/courier/imapd and upping the IMAP_ULIMITD to 131072 as I saw mentioned on the thread, and it made the trick. When running, it doesn't look like courier is using that much memory though.

