2013-02-14 66 views
0

我嘗試使用C++(https://sites.google.com/site/roboticssaurav/strokewidthnokia)上編寫的文本檢測應用程序,但代碼處於掛起狀態。我發現這個問題的根源在於其中一個函數使用大型圖形50 K頂點和150 K邊緣,並且所有代碼都會在調用鄰接列表「clear」時掛起。在提高鄰接列表上掛起明確

std::vector< std::vector<Point2d> > 
findLegallyConnectedComponents (IplImage * SWTImage, 
           std::vector<Ray> & rays) 
{ 
... 
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph; 
... 
Graph g(num_of_vertices); 
... 
} 

離開這個函數後,g.clear()會被調用,程序掛在這個上面。我如何擺脫這個bug?謝謝。

回答

1

所以這個問題在發佈模式中消失了,這就是解決方案。

+0

尼斯趕上...這個確切的問題把我難住了。 – zorlack 2013-03-07 21:41:20

0

此問題僅在調試模式下發生。

如果你不能像我一樣使用發佈模式。

您可以手動清除m_edges,然後清除圖中的m_vertices以避免此問題。

像如下:

Graph g; 
// ....... 

// clear it on DEBUG mode to avoid hanges 
g.m_edges.clear(); 
g.m_vertices.clear(); 
g.clear();