WordPress query mechanism drag whole set of results into memory so they are not suited for such large chunks of information.
You can use numberposts
and offset
in get_posts()
to split process into chunks. I am not sure if you will be able to do it in single run even then, so you might need to save how many chunks you processed and start from there next time.