backwards compatible grep for memory

Potentially will work for 5.5 and earlier, as well as 6 and 6.5 (tested with 6.5)
Merge pull request #527 from leeclemens/patch-4

backwards compatible grep for memory