Looping out a lot of entries.
There isn't really a good way to extract large chunks of Craft entries using the core features in Twig. Every entry you fetch is a EntryModel and those take up some memory due to relations and other stuff in Yii's ActiveRecord class.

What you can do is to create your own custom Plugin that does the same thing but queries the database directly instead, by-passing Crafts EntryModels and just giving you the dataset results directly.

Here's some resources on getting started with Plugin development:

Craft official documentation: https://craftcms.com/docs/plugins/introduction

From StraightUpCraft: https://straightupcraft.com/plugin-development

A wrapper for creating a Plugin default setup: http://pluginfactory.io/