having to process a file with 300000 lines
What is a "line" in this context? Rows of the spreadsheet? How many columns, i.e. how many cells?
Assume there are 1 million cells and that each cell occupies 100 bytes on the average you would need 100 MB to store the worksheet. During reading, the worksheet xml is loaded into memory as well. But i doubt that memory usage exceeds several hundreds of MB -- far away from your 8GB. How much of your memory is occupied? Or did you compile a 32-bit program where you can run out of memory relatively easily? Compile a 64-bit program so that you can access all the free space of the 8GB.
It also depends on what you want to do with the data? Display in a grid? Then there's no other option (BTW - who should look at 1 million cells?). On the other hand, if you want to do an analysis on the fly without storing all cells in a worksheet you can go to "virtual mode" which disposes each cell after reading, of course after giving you the opportunity to analyze the cell. Virtual mode is explained in the
wiki article, and there are also some demos among the examples provided.