Tie::File keeps an index of every line it encounters (which is every line up to the deepest one requested). For a 5GB file, that's a giant amount of memory. The memory option does not affect the size of this index.
Comment on Re^2: Out of memory error while Reading 5GB text file