This is not a complete answer (sorry! ) but the wacky memory.limit() result is a known bug, with work underway.
memory.limit()
Some previous discussion here:
And the Github issue is here: