It is probably just running out of memory trying to retrieve that many records.
You can either limit the number of records displayed on the page and add pagination, or increase the memory limit, or refine the query if it includes columns you aren't using to reduce the memory load.