CA-135774 low memory situation fix V2

I changed the algorithm of entering and exiting low memory mode and hopefully addressed your other comments in the last pull request. Details of the algorithm are in the commit message.

I certainly prefer this algorithm. It seems to behave OK in testing.