I'm running postgres 9.1 and getting this same bug.
Am running the client in UTF-8 (chcp 65001), have set the environment
variable PGCLIENTENCODING to UTF8, set the terminal font to Lucida
psql returns "Out of memory error" for any simple query (e.g. SELECT
MAX(date) FROM mytable;), even on small tables.