ZigRazor/CXXGraph

Smart Pointers use

ZigRazor opened this issue · 7 comments

why don't use smart pointers?
I think is better to introduce and use smart pointers in all code

So what to do???
Adding some documentation about smart pointers or some code using examples??

I think there is the need to rework the code to let all the pointers change in smart pointers

I think smart pointers have to be introduced as it's hard to manually free all dynamic allocated memory in a growing project. And by the way, may I ask a question here @ZigRazor ? I'm confused about dynamic allocated memory in part of benchmark-related code. I dont find some place in part of benchmark-related code where we free those dynamic allocated memory to which static variables(pointers) point, and each .cpp has a copy of them because each .cpp include utility.h once respectively. So it seems a huge memory leak problem exists?

`//Static Generation
static auto nodes = generateRandomNodes(100000, 2);

static auto edges = generateRandomEdges(100000, nodes);

static auto undirectedEdges = generateRandomUndirectedEdges(100000, nodes);

static auto cit_graph_ptr = readGraph("CitHepPh");`

hi @suncanghuai good annotations,

I think is the moment to do this, before the stable release.

In benchmark related code, the dynamic allocated memory is free only when the program is terminated. But is allocated only one time because the variable is static and the include file is protected by an #ifndef condition.

So the memory is allocated by the first one that use it and then never released inside the execution, but only when the executable terminates, this because these variables are used in different point of the code.

sbaldu commented

Hi @ZigRazor, can you assign me this issue if it's still available, please?

Yes, I assign it to you @sbaldu !

Closed by PR #316