I have written a converter that takes openstreetmap xml files and converts them to a binary runtime rendering format that is typically about 10% of the original size. Input file
there's a good technique for that, is to store some instances into files, and after getting them when you need to use them.
this technique is used by many open source software like Doxygen to be scalable when a big quantity of memory is needed.