Nervous investors are hoping to ride out looming financial storms by staying in cash.

In recent weeks global fund managers have increased their cash stockpiles to the highest level since November 2001, the scary period right after the 9/11 terror attacks, according to a Bank of America Merrill Lynch survey.

"Investors have a mountain of cash," Michael Hartnett, Bank of America's chief investment strategist, wrote in a report.

The defensive maneuvering is a further sign that some investors are too scared to be stuck holding risky stocks and bonds ahead of potential upcoming shocks. The biggest fear among survey respondents is Brexit, the U.K. referendum on leaving the European Union taking place next week. Rising support in favor of dumping the EU has already begun to cause market turmoil in recent days.

Fund managers' average cash allocation jumped to 5.7% this month, surpassing even the levels during the 2008 Wall Street meltdown or the 2011 U.S. debt ceiling debacle, BofA said. Hartnett noted other "big bear signals" as well, including investors displaying the lowest risk appetite in four years.

Related: Market turmoil: Is there anywhere left to hide?

This is hardly the only time lately that investors have showered love on cash. During a recent stretch between July and February, BofA said cash and money market funds were actually the world's most popular asset class, attracting over $200 billion of inflows.

Still, it's a tough time to be sitting in cash. Extremely low interest rates around the world mean money in the bank earns virtually nothing. And when inflation is factored in, cash actually loses value.

The average money market and savings account carries an annual percentage yield of just 0.11%, according to Bankrate.com. Even savvy savers who shop around for better rates aren't fetching much more than 1% from online banks.

But that's better than losing money, which most people think is likely with volatile stocks. It also doesn't help that investors have very few places to hide these days. Government debt is normally viewed as a safe haven, but it's hard to justify buying bonds, when there's nothing much to earn. German bond yields went negative for the first ever this week and the U.S. Treasury yield closed at a four-year low of 1.61%.

It's no wonder that BofA said the percentage of investors who think equity and bond markets are overvalued is the fourth-highest since it began tracking in 2003.

Related: How much will U.S. stocks drop if Brexit happens?

What's more surprising is that fund managers don't think the U.K. will dump the EU next week. Despite the recent flight to cash, two-thirds of investors surveyed think Brexit is either "unlikely" or "not at all likely."

Similarly, fund managers are feeling more bullish about the outlook for global growth and corporate profits. Both measures hit six-month highs in the June survey.

The other good news is that BofA considers high levels of cash a contrarian buy signal for stocks, in part because it leaves investors with lots of cash to put to work.

"Negative summer 'events' could thus quickly become tradable buying opportunities," Hartnett wrote.