Malaysia is ahead of China in terms of the size of its direct foreign investment (FDI) into Africa and the gap is widening, according to United Nations data published on Monday.

A survey of foreign investment into and out of the five BRICS countries, published on the eve of their summit in South Africa and while new Chinese President Xi Jinping visits the continent, revealed that China's march into Africa has lagged behind the flow of cash from Kuala Lumpur.

(Read More: Will BRICs Outperform the US in 2013?)

FDI, which includes crossborder mergers and acquisitions and investments in startup projects abroad, can give clues about economic confidence and future trade flows. For Malaysia, the big spenders in Africa include firms such as Petronas and Sime Darby.

Malaysia was the third biggest investor in Africa in 2011, the latest year for which data is available, behind France and the United States, pushing China and India into fourth and fifth positions.

(Read More: Malaysia's MISC Rises on Petronas Buyout Offer)

France and the United States also have the largest historical stock of investments in Africa, with Britain in third place and Malaysia in fourth, followed by South Africa, China and India.

The other two BRICS - Russia and Brazil - have minimal direct investments in the continent, according to the data from the U.N. economic think tank UNCTAD.

Malaysia's portfolio of global FDI more than quintupled over the past decade to reach $106 billion by the end of 2011. Of that, $19.3 billion was in Africa, more than the $16 billion of African investments owned by China and the $14 billion held by India.

(Read More: China's 'Internationalization' Won't Be Painless: WTO's Lamy)

The five BRICS have escalated their investments in Africa from almost nothing in the 2000-2002 to 4 percent of their outward FDI in 2009-2011, making Africa a much more important investment destination for them than it is for the European Union or the United States.

By contrast Malaysia sent 24 percent of its outward FDI to Africa in 2011, mainly to Mauritius in that year.