我的確有一個問題涉及爲幾個結構分配內存的性能降低。 我有的看起來像一個結構:見下文結構的內存分配(低性能)
typedef struct _node
{
// Pointer to leaves & neigbours
struct _node *children[nrChild], *neighb[nrNeigh];
// Pointer to parent Node
struct _node *parentNode;
struct _edgeCorner *edgePointID[nrOfEdge];
int indexID; // Value
double f[latDir]; // Lattice Velos
double rho; // Density
double Umag; // Mag. velocity
int depth; // Depth of octree element
} node
在我的代碼開始,我就必須創建他們中的很多(100.000 - 1.000.000)由 使用:
tree = new node();
並啓動後面的元素。 不幸的是,這是很慢,因此,你們有沒有想過改善性能?
當然,這很可能不會與他的編譯器一起工作,並且如果它有更好的機會,它將不具有正確的語義。 (使用'unique_ptr'可能不是正確的解決方案。) – 2013-03-11 12:26:53
它被標記爲VS2010,因此它有很好的機會與編譯器一起工作,並獲得預期的結果。 – Puppy 2013-03-11 12:35:19
好傢伙, 因爲我感興趣的是使用Boost.Pool庫看到的性能差異,我試圖做同樣的
'樹=新節點();'
與升壓池庫,像「DeadMG」使用
'的boost :: fast_pool_allocator繞着彎
現在的問題是我不知道的語法通過使用boost :: fast_pool_allocator做同樣的。 任何人都可以幫助我嗎? – Sambo 2013-03-22 11:24:28