Out of memory or corrupted data?

When doing a pg_dump I run into the following error:

...
ERROR:  out of memory
DETAIL:  Failed on request of size 536870912.
STATEMENT:  COPY public.crm_department_output (crm_department_output_id, document_type, document_format_type, crm_department_id, document_date, origin_type, origin_id, owner_id, log_creation_user, log_creation_dt, log_modification_user, log_modification_dt, document, checkout_dt, checkout_user, checkin_dt, name, document_sequence_integer, amount_excl_vat, amount_incl_vat, glb_currency_id, currency_amount_excl_vat, currency_amount_incl_vat, document_reference, crm_contactperson_id, mailed_dt, faxed_dt, cost_price, printed_dt, start_date, end_date) TO stdout;

How can I increase the memory that can be used by postgres?

A google search showed me that this error could be caused by corrupted data.
This table has one field of type bytea (document). The following query does not give an error:

select length(document) from crm_department_output

Largest values are around 90 million. How could the corrupted record(s) be found if present?

I’m using postgresql 8.4 shipped with servoy 5.2

Kind Regards,

Found it, turned out to be corrupted data! Hard work, like finding a needle in a haystack…

When data is corrupted is there no way to (partially) restore it?