You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void GraphStd<vid_t, eoff_t>::COOtoCSR() {
...
247 if (_prop.is_directed_by_degree()) {
248 if (_prop.is_print())
249 std::cout << "Creating degree-directed graph ..." << std::endl;
250 eoff_t counter = 0;
251 vid_t u, v;
252 vid_t vid_small, vid_large;
253 degree_t deg_u, deg_v;
254 coo_t* coo_edges_tmp = new coo_t[_nE];
255 degree_t* _out_degrees_tmp = new degree_t[_nV]();
256 degree_t* _in_degrees_tmp;
257 if (_structure.is_reverse())
258 _in_degrees_tmp = new degree_t[_nV]();
259 for (eoff_t i=0; i<_nE; i++) {
260 u = _coo_edges[i].first;
261 v = _coo_edges[i].second;
262 deg_u = _out_degrees[u];
263 deg_v = _out_degrees[v];
264 if ((deg_u < deg_v) || ((deg_u == deg_v) && (u < v))) {
265 coo_edges_tmp[counter++] = {u, v};
266 }
267 }
268 _coo_edges = coo_edges_tmp;
269 _nE = counter;
270
271 if (_structure.is_directed() && _structure.is_reverse()) {
272 for (eoff_t i = 0; i < _nE; i++) {
273 _out_degrees_tmp[_coo_edges[i].first]++;
274 _in_degrees_tmp[_coo_edges[i].second]++;
275 }
276 }
277 else {
278 for (eoff_t i = 0; i < _nE; i++)
279 _out_degrees_tmp[_coo_edges[i].first]++;
280 }
281 _out_degrees = _out_degrees_tmp;
282 if (_structure.is_reverse())
283 _in_degrees = _in_degrees_tmp;
284 }
...
}
There are memory leaks in line 268, 281, and 283 (e.g. Memory pointed by _in_degrees dangles after executing _in_degrees = _in_degrees_tmp). I assume these are not the only memory leaks in the code. Using smart pointers (unique_ptr) can prevent this (e.g. if _in_degrees and _in_degrees_tmp are unique_ptr types, this is not a memory leak). We should consider replacing raw pointers with smart pointers or std:vector.
The text was updated successfully, but these errors were encountered:
OK, but I still think we should use unique_ptr to point allocated memory than raw pointers. This isn’t just for the GraphStd class, and unique_ptr can be much safer and unique_ptr does not incur much performance/space overhead.
From: ogreen <[email protected]>
Reply-To: gpuopenanalytics/graph-research <[email protected]>
Date: Wednesday, January 9, 2019 at 5:51 PM
To: gpuopenanalytics/graph-research <[email protected]>
Cc: Seunghwa Kang <[email protected]>, Author <[email protected]>
Subject: Re: [gpuopenanalytics/graph-research] [BUG] Memory leaks and smart pointers (#21)
We may get rid of this class (GraphStd) is it Hornet's static graph data structure and will become redundant with cuGraph and its CSR data structure.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#21 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Aru6kWkwwpCGd4jt4xuzXAwCiYBL_9k1ks5vBpyagaJpZM4Z4hnZ>.
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
In xlib/src/Graph/GraphStd.cpp
There are memory leaks in line 268, 281, and 283 (e.g. Memory pointed by _in_degrees dangles after executing _in_degrees = _in_degrees_tmp). I assume these are not the only memory leaks in the code. Using smart pointers (unique_ptr) can prevent this (e.g. if _in_degrees and _in_degrees_tmp are unique_ptr types, this is not a memory leak). We should consider replacing raw pointers with smart pointers or std:vector.
The text was updated successfully, but these errors were encountered: